add config.ini and read it with configparse

This commit is contained in:
fram3d 2023-06-21 00:30:32 +02:00
parent 1e2f119f7f
commit 8f1aaeb417
Signed by: fram3d
GPG Key ID: 938920E709EEA32A
2 changed files with 19 additions and 6 deletions

7
luser/config.ini Normal file
View File

@ -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

View File

@ -6,13 +6,19 @@ import subprocess
import random import random
import base64 import base64
import os import os
import configparser
LDAPHOST = 'ldap.example.org' CONFIG_PATH = "./config.ini"
LDAPADMINNAME = 'cn=admin,dc=example,dc=org'
LDAPPASS = 'verysecr3t' config = configparser.ConfigParser()
USERBASE = 'ou=Users,dc=example,dc=org' config.read(CONFIG_PATH)
ALTUSERBASE = '' # Optional
CAPTCHA_PATH = '/var/luser/luser/static/account/register/captcha_img/' 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']) @app.route('/account/changepassword/', methods=['POST', 'GET'])
def changepassword(): def changepassword():