From 7e5fd33c77c63b2b206571cf9e91e28e9e165caa Mon Sep 17 00:00:00 2001
From: root <root@srv8.soctools.grena.ge>
Date: Tue, 12 Apr 2022 14:37:05 +0400
Subject: [PATCH] remove user-mgmt-ui folder to convert as submoddule
---
user-mgmt-ui/README.md | 3 --
user-mgmt-ui/main.py | 65 --------------------------------
user-mgmt-ui/static/style.css | 33 ----------------
user-mgmt-ui/templates/main.html | 57 ----------------------------
user-mgmt-ui/wsgi.py | 1 -
5 files changed, 159 deletions(-)
delete mode 100644 user-mgmt-ui/README.md
delete mode 100644 user-mgmt-ui/main.py
delete mode 100644 user-mgmt-ui/static/style.css
delete mode 100644 user-mgmt-ui/templates/main.html
delete mode 100644 user-mgmt-ui/wsgi.py
diff --git a/user-mgmt-ui/README.md b/user-mgmt-ui/README.md
deleted file mode 100644
index b66c556..0000000
--- a/user-mgmt-ui/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# SOCTools user management web
-
-Simple web GUI for user management in SOCtools.
diff --git a/user-mgmt-ui/main.py b/user-mgmt-ui/main.py
deleted file mode 100644
index bd025aa..0000000
--- a/user-mgmt-ui/main.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# Example of minimal working WSGI script
-from flask import Flask, render_template, request, make_response, redirect, flash
-
-from flask_wtf import FlaskForm
-from wtforms import StringField
-from wtforms.validators import DataRequired, Email
-
-import subprocess
-
-app = Flask(__name__)
-app.secret_key = "ASDF1234 - CHANGE ME!"
-
-
-class AddUserForm(FlaskForm):
- username = StringField("Username", validators=[DataRequired()])
- cn = StringField("Common name (CN)", validators=[DataRequired()])
- firstname = StringField("First name", validators=[])
- lastname = StringField("Last name", validators=[])
- # TODO what about CN/DN - construct from first+last name or allow to redefine?
- email = StringField("Email", validators=[DataRequired(), Email()])
-
-
-@app.route("/", methods=["GET", "POST"])
-def main():
- # TODO Load existing users (from where?)
- users = [{
- "firstname": "User1",
- "lastname": "SOC",
- "username": "user1",
- "email": "user1@example.org",
- "DN": "CN=User1Soctools",
- "CN": "User1Soctools",
- },{
- "firstname": "User2",
- "lastname": "SOC",
- "username": "user2",
- "email": "user2@example.org",
- "DN": "CN=User2Soctools",
- "CN": "User2Soctools",
- }]
-
- # Add user
- form_add_user = AddUserForm()
- if form_add_user.validate_on_submit():
- # TODO check that username doesn't exist, yet (and check validity, i.e. special characters etc.)
- # TODO add user
- result = subprocess.run(["echo", "test"], capture_output=True)
- if result.returncode == 0:
- flash(f'User "{form_add_user.username.data}" successfully created.', "success")
- else:
- flash(f'Error when creating user: {result.stderr}', "error")
-
- return render_template("main.html", **locals())
-
-
-# TODO AJAX endpoint to delete user
-
-# TODO edit user? User detail page?
-
-# TODO certificates??
-
-
-# When the script is run directly, run the application on a local development server.
-if __name__ == '__main__':
- app.run()
diff --git a/user-mgmt-ui/static/style.css b/user-mgmt-ui/static/style.css
deleted file mode 100644
index f441703..0000000
--- a/user-mgmt-ui/static/style.css
+++ /dev/null
@@ -1,33 +0,0 @@
-body {
- background-color: #fff;
-}
-
-table {
- border: 1px solid black;
- background: #ccc;
- min-width: 50%;
-}
-td {
- background: #fff;
-}
-
-
-p {
- background-color: #fff;
- padding: 0.5em;
-}
-
-.errors {
- background-color: #fcc;
- color: #c00;
-}
-
-ul.flashes {
- color: #009;
-}
-li.flash-error {
- color: #900;
-}
-li.flash-success {
- color: #090;
-}
diff --git a/user-mgmt-ui/templates/main.html b/user-mgmt-ui/templates/main.html
deleted file mode 100644
index edf70bf..0000000
--- a/user-mgmt-ui/templates/main.html
+++ /dev/null
@@ -1,57 +0,0 @@
-<!doctype html>
-<html>
-<head>
- <meta charset="utf-8">
- <title>SOCtools user management</title>
- <link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
-</head>
-<body>
-{# Flash messages #}
-{% with messages = get_flashed_messages(with_categories=true) %}
- {% if messages %}
- <div class="flashes">
- {% for category, message in messages %}
- <li class="flash-{{category}}">{{ message }}</li>
- {% endfor %}
- </div>
- {% endif %}
-{% endwith %}
-
-<h1>SOCtools - User management</h1>
-
-<table>
-<tr><th>Username</th><th>First name</th><th>Last name</th><th>CN</th><th>email</th><th></th>
-{% for user in users %}
-<tr>
-<td>{{ user.username }}</td>
-<td>{{ user.firstname }}</td>
-<td>{{ user.lastname }}</td>
-<td>{{ user.CN }}</td>
-<td>{{ user.email }}</td>
-<td>... {#TODO actions#}</td>
-</tr>
-{% endfor %}
-</table>
-
-<p></p>
-
-<h2>Add new user</h2>
-<form action="{{ url_for("main") }}" method="POST">
-{% if form_add_user.errors %}
- <ul class="errors">
- {% for field, errors in form_add_user.errors.items() %}
- <li>{{ form_add_user[field].label if field else "" }}: {{ ' | '.join(errors) }}</li>
- {% endfor %}
- </ul>
-{% endif %}
- {{ form_add_user.csrf_token }}
- {{ form_add_user.username.label }} {{ form_add_user.username(size=20) }}<br>
- {{ form_add_user.firstname.label }} {{ form_add_user.firstname(size=20) }}<br>
- {{ form_add_user.lastname.label }} {{ form_add_user.lastname(size=20) }}<br>
- {{ form_add_user.cn.label }} {{ form_add_user.cn(size=20) }}<br>
- {{ form_add_user.email.label }} {{ form_add_user.email(size=20) }}<br>
- <input type="submit" value="Add user">
-</form>
-
-</body>
-</html>
\ No newline at end of file
diff --git a/user-mgmt-ui/wsgi.py b/user-mgmt-ui/wsgi.py
deleted file mode 100644
index 45e6903..0000000
--- a/user-mgmt-ui/wsgi.py
+++ /dev/null
@@ -1 +0,0 @@
-from main import app as application
\ No newline at end of file
--
GitLab