Commit 805d4729 authored by JackV's avatar JackV
Browse files

Make the account management application standalone

parent 206162e3
......@@ -9,8 +9,7 @@ RUN apk add -U python3 py3-gunicorn && \
COPY /uus
COPY admin /uus/admin
COPY uus_mng /
......@@ -7,9 +7,9 @@ A simple CLI is provided to add, modify and delete admin users. `REDIS_URL` must
Run `flask` to get the list of commands.
In the docker container you can run `uus` directly to get to the CLI, for example
In the docker container you can run `uus_mng` directly to get to the CLI, for example
$ docker exec -it uus_uus_1 uus adduser admin
$ docker exec -it uus_uus_1 /uus_mng adduser admin
\ No newline at end of file
#!/usr/bin/env python3
import crypt
import click
import redis
import os
redis_store = None
default_redis_url = os.environ.get('REDIS_URL', 'redis://')
from . import app, redis_store, redis_key_for_user
@click.option("--redisurl", "-u", help="Redis DB url", default=default_redis_url)
def cli(redisurl):
global redis_store
redis_store = redis.from_url(redisurl)
@click.option("--passwd", "-p", prompt="Password", help="Password", hide_input=True)
def adduser(username, passwd):
"""Add UUS admin user"""
cryptpwd = crypt.crypt(passwd)
redis_store.set(redis_key_for_user(username), cryptpwd)
redis_store.set('usr.' + username, cryptpwd)
@click.option("--passwd", "-p", prompt="Password", help="Password", hide_input=True)
def passwd(username, passwd):
......@@ -22,8 +32,12 @@ def passwd(username, passwd):
adduser(username, passwd)
def deluser(username):
"""Delete UUS admin user"""
redis_store.delete('usr.' + username)
if __name__ == '__main__':
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment