diff --git a/user-mgmt-ui/README.md b/user-mgmt-ui/README.md deleted file mode 100644 index b66c556f65e4e5ba734f3247e583931b181141af..0000000000000000000000000000000000000000 --- 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 bd025aa4e86bb078b2512f2acad891bafa0e02eb..0000000000000000000000000000000000000000 --- 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 f441703f0cf1c7c95c2bf60d234584813d2cbc08..0000000000000000000000000000000000000000 --- 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 edf70bfd7cf1172358ce64ee1af68580b575344c..0000000000000000000000000000000000000000 --- 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 45e690386131a12112be0ece4e9c26a916640b3e..0000000000000000000000000000000000000000 --- a/user-mgmt-ui/wsgi.py +++ /dev/null @@ -1 +0,0 @@ -from main import app as application \ No newline at end of file