diff options
author | Lars Wirzenius <liw@liw.fi> | 2017-04-16 12:56:00 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2017-04-16 12:56:00 +0300 |
commit | 88dd2cfd71b213b63c264db6eab6c1ea8552ad9b (patch) | |
tree | a9c4d2ac966ca093bd6decd8ea72cda62ed72e48 | |
parent | 489389f2ace4a2cfec30736d090ae039e0b81095 (diff) | |
download | distixapi-88dd2cfd71b213b63c264db6eab6c1ea8552ad9b.tar.gz |
Change distix-backend to load user database from a file
-rwxr-xr-x | distix-backend | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/distix-backend b/distix-backend index e4ee380..ea621c0 100755 --- a/distix-backend +++ b/distix-backend @@ -4,6 +4,7 @@ import os import random import sys +import yaml import bottle @@ -11,22 +12,6 @@ import distixapi -users = { - 'users': { - 'fooser': { - 'salt': 'nacl', - 'password': distixapi.encrypt_password('nacl', 'password'), - 'scopes': ['get', 'put'], - }, - 'no': { - 'salt': 'nacl', - 'password': distixapi.encrypt_password('nacl', 'password'), - 'scopes': [], - }, - }, -} - - class AuthenticationPlugin(object): name = 'AuthenticationPlugin' @@ -56,6 +41,7 @@ def version(): pid_file = sys.argv[1] port_file = sys.argv[2] +users_file = sys.argv[3] @@ -76,5 +62,5 @@ port = random.randint(1025, 32767) with open(port_file, 'w') as f: f.write('{}\n'.format(port)) - +users = yaml.safe_load(open(users_file)) bottle.run(port=port, quiet=True, plugins=[AuthenticationPlugin()]) |