summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-04-16 12:56:00 +0300
committerLars Wirzenius <liw@liw.fi>2017-04-16 12:56:00 +0300
commit88dd2cfd71b213b63c264db6eab6c1ea8552ad9b (patch)
treea9c4d2ac966ca093bd6decd8ea72cda62ed72e48
parent489389f2ace4a2cfec30736d090ae039e0b81095 (diff)
downloaddistixapi-88dd2cfd71b213b63c264db6eab6c1ea8552ad9b.tar.gz
Change distix-backend to load user database from a file
-rwxr-xr-xdistix-backend20
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()])