From 6c4bbb3dca510008b84457593703b960823c12ea Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Wed, 14 Oct 2020 18:30:05 +0200 Subject: [PATCH] add password support --- src/risotto/config.py | 29 +++++++++++++++++++++++++++++ src/risotto/dispatcher.py | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/risotto/config.py b/src/risotto/config.py index a3462bc..a78ac41 100644 --- a/src/risotto/config.py +++ b/src/risotto/config.py @@ -1,6 +1,7 @@ from os import environ from os.path import isfile from configobj import ConfigObj +from uuid import uuid4 CONFIG_FILE = environ.get('CONFIG_FILE', '/etc/risotto/risotto.conf') @@ -88,6 +89,28 @@ if 'IMAGE_PATH' in environ: IMAGE_PATH = environ['IMAGE_PATH'] else: IMAGE_PATH = config.get('IMAGE_PATH', '/tmp') +if 'PASSWORD_ADMIN_USERNAME' in environ: + PASSWORD_ADMIN_USERNAME = environ['PASSWORD_ADMIN_USERNAME'] +else: + PASSWORD_ADMIN_USERNAME = config.get('PASSWORD_ADMIN_USERNAME', 'risotto') +if 'PASSWORD_ADMIN_EMAIL' in environ: + PASSWORD_ADMIN_EMAIL = environ['PASSWORD_ADMIN_EMAIL'] +else: + # this parameter is mandatory + PASSWORD_ADMIN_EMAIL = config['PASSWORD_ADMIN_EMAIL'] +if 'PASSWORD_ADMIN_PASSWORD' in environ: + PASSWORD_ADMIN_PASSWORD = environ['PASSWORD_ADMIN_PASSWORD'] +else: + # this parameter is mandatory + PASSWORD_ADMIN_PASSWORD = config['PASSWORD_ADMIN_PASSWORD'] +if 'PASSWORD_DEVICE_IDENTIFIER' in environ: + PASSWORD_DEVICE_IDENTIFIER = environ['PASSWORD_DEVICE_IDENTIFIER'] +else: + PASSWORD_DEVICE_IDENTIFIER = config.get('PASSWORD_DEVICE_IDENTIFIER', uuid4()) +if 'PASSWORD_URL' in environ: + PASSWORD_URL = environ['PASSWORD_URL'] +else: + PASSWORD_URL = config.get('PASSWORD_URL', 'https://localhost:8001/') def dsn_factory(database, user, password, address=DB_ADDRESS): @@ -110,6 +133,12 @@ _config = {'database': {'dsn': dsn_factory(RISOTTO_DB_NAME, RISOTTO_DB_USER, RIS 'sql_dir': SQL_DIR, 'tmp_dir': TMP_DIR, }, + 'password': {'admin_username': PASSWORD_ADMIN_USERNAME, + 'admin_email': PASSWORD_ADMIN_EMAIL, + 'admin_password': PASSWORD_ADMIN_PASSWORD, + 'device_identifier': PASSWORD_DEVICE_IDENTIFIER, + 'service_url': PASSWORD_URL, + }, 'cache': {'root_path': CACHE_ROOT_PATH}, 'servermodel': {'internal_source_path': SRV_SEED_PATH, 'internal_source': 'internal'}, diff --git a/src/risotto/dispatcher.py b/src/risotto/dispatcher.py index 6b8d740..7ae34e1 100644 --- a/src/risotto/dispatcher.py +++ b/src/risotto/dispatcher.py @@ -349,7 +349,7 @@ class Dispatcher(register.RegisterDispatcher, sql = ''' SELECT UserId FROM UserUser - WHERE UserLogin = $1 + WHERE Login = $1 ''' user_id = await connection.fetchval(sql, user_login)