From 88dd2cfd71b213b63c264db6eab6c1ea8552ad9b Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sun, 16 Apr 2017 12:56:00 +0300 Subject: Change distix-backend to load user database from a file --- distix-backend | 20 +++----------------- 1 file 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()]) -- cgit v1.2.1