From 8f1aaeb417f08e1b5efa228f51ac2812b3cbb9d1 Mon Sep 17 00:00:00 2001 From: fram3d Date: Wed, 21 Jun 2023 00:30:32 +0200 Subject: [PATCH] add config.ini and read it with configparse --- luser/config.ini | 7 +++++++ luser/routes.py | 18 ++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) create mode 100644 luser/config.ini diff --git a/luser/config.ini b/luser/config.ini new file mode 100644 index 0000000..00fa585 --- /dev/null +++ b/luser/config.ini @@ -0,0 +1,7 @@ +[credentials] +LDAPHOST = ldap.example.org +LDAPADMINNAME = cn=admin,dc=example,dc=org +LDAPPASS = verysecr3t +USERBASE = ou=Users,dc=example,dc=org +CAPTCHA_PATH = /var/luser/luser/static/account/register/captcha_img/ +# ALTUSERBASE = ou=UsersAlt,dc=example,dc=org diff --git a/luser/routes.py b/luser/routes.py index 23de665..7bb9d85 100644 --- a/luser/routes.py +++ b/luser/routes.py @@ -6,13 +6,19 @@ import subprocess import random import base64 import os +import configparser -LDAPHOST = 'ldap.example.org' -LDAPADMINNAME = 'cn=admin,dc=example,dc=org' -LDAPPASS = 'verysecr3t' -USERBASE = 'ou=Users,dc=example,dc=org' -ALTUSERBASE = '' # Optional -CAPTCHA_PATH = '/var/luser/luser/static/account/register/captcha_img/' +CONFIG_PATH = "./config.ini" + +config = configparser.ConfigParser() +config.read(CONFIG_PATH) + +LDAPHOST = config.get('credentials', 'LDAPHOST') +LDAPADMINNAME = config.get('credentials', 'LDAPADMINNAME') +LDAPPASS = config.get('credentials', 'LDAPPASS') +USERBASE = config.get('credentials', 'USERBASE') +ALTUSERBASE = config.get('credentials', 'ALTUSERBASE') +CAPTCHA_PATH = config.get('credentials', 'CAPTCHA_PATH') @app.route('/account/changepassword/', methods=['POST', 'GET']) def changepassword():