Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
jacotsu
uus
Commits
805d4729
Commit
805d4729
authored
Feb 11, 2019
by
JackV
Browse files
Make the account management application standalone
parent
206162e3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Dockerfile
View file @
805d4729
...
...
@@ -9,8 +9,7 @@ RUN apk add -U python3 py3-gunicorn && \
ENV
FLASK_APP=uus
COPY
uus.py /uus
COPY
admin /uus/admin
COPY
uus_mng /
EXPOSE
8000
...
...
README.md
View file @
805d4729
...
...
@@ -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
Password:
```
\ No newline at end of file
```
uus
/management_cli.py
→
uus
_mng
100644 → 100755
View file @
805d4729
#!/usr/bin/env python3
import
crypt
import
click
import
redis
import
os
redis_store
=
None
default_redis_url
=
os
.
environ
.
get
(
'REDIS_URL'
,
'redis://127.0.0.1:6379/0'
)
from
.
import
app
,
redis_store
,
redis_key_for_user
@
click
.
group
()
@
click
.
option
(
"--redisurl"
,
"-u"
,
help
=
"Redis DB url"
,
default
=
default_redis_url
)
def
cli
(
redisurl
):
global
redis_store
redis_store
=
redis
.
from_url
(
redisurl
)
@
app
.
cli
.
command
()
@
cli
.
command
()
@
click
.
argument
(
"username"
)
@
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
)
@
app
.
cli
.
command
()
@
cli
.
command
()
@
click
.
argument
(
"username"
)
@
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
)
@
app
.
cli
.
command
()
@
cli
.
command
()
@
click
.
argument
(
"username"
)
def
deluser
(
username
):
"""Delete UUS admin user"""
redis_store
.
delete
(
redis_key_for_user
(
username
))
redis_store
.
delete
(
'usr.'
+
username
)
if
__name__
==
'__main__'
:
cli
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment