Compare commits

..

3 Commits

Author SHA1 Message Date
bretello
f6429b4ea3
settings: use abbiamoundominio.org 2024-06-15 18:27:41 +02:00
bretello
0dcdabe339
fix error handling (errors were returning 500) 2024-06-15 18:26:45 +02:00
unit
7a3d365928 added tls as option 2021-02-08 18:21:31 +01:00
2 changed files with 9 additions and 8 deletions

10
app.py
View File

@ -33,10 +33,9 @@ def post_index():
try: try:
ldap_change_password(form('username'), ldap_change_password(form('username'),
form('old-password'), form('new-password')) form('old-password'), form('new-password'))
except Error as e: except Exception as exc:
print("Unsuccessful attemp to change password for {}: {}" print(f"Unsuccessful attempt to change password for {form('username')}: {exc=}")
.format(form('username'), str(e))) return error(str(exc))
return error(str(e))
print("Password successfully changed for: {}" print("Password successfully changed for: {}"
.format(form('username'))) .format(form('username')))
@ -58,7 +57,8 @@ def ldap_change_password(username, old, new):
l = ldap.initialize(CONF['ldap']['host']) l = ldap.initialize(CONF['ldap']['host'])
l.set_option(ldap.OPT_X_TLS_CACERTFILE, CONF['ldap']['tls_cacert']) l.set_option(ldap.OPT_X_TLS_CACERTFILE, CONF['ldap']['tls_cacert'])
l.set_option(ldap.OPT_X_TLS, ldap.OPT_X_TLS_DEMAND) l.set_option(ldap.OPT_X_TLS, ldap.OPT_X_TLS_DEMAND)
l.start_tls_s() if CONF['ldap']['tls'] == "True":
l.start_tls_s()
l.simple_bind_s(dn_name, old) l.simple_bind_s(dn_name, old)
l.passwd_s(dn_name, old, new) l.passwd_s(dn_name, old, new)
l.unbind_s() l.unbind_s()

View File

@ -1,9 +1,10 @@
[html] [html]
page_title = Change your password on unit.macaomilano.org page_title = Change your password on unit.abbiamoundominio.org
[ldap] [ldap]
host = ldap://unit.macaomilano.org:389 host = ldap://localhost:389
base = ou=Hackers,dc=unit,dc=macaomilano,dc=org base = ou=Hackers,dc=unit,dc=abbiamoundominio,dc=org
tls = True
tls_cacert = /etc/ssl/cert.pem tls_cacert = /etc/ssl/cert.pem
[server] [server]