Compare commits

..

3 Commits

Author SHA1 Message Date
Ferdinand Thiessen 4ba7aeeffa [auth_ldap] modify_role has to be called before the update to change it on the backend 2021-07-29 17:10:52 +02:00
Ferdinand Thiessen ea782b40d6 [auth_ldap] Fix typo in __init__ 2021-07-29 16:45:26 +02:00
Ferdinand Thiessen 50ccfac565 [auth_ldap] Allow more configuration
* Allow configuring the password hash (SSHA, PBKDF2 or Argon2)
* Allow setting custom dn templates for users and groups to e.g. allow "ou=people" or "ou=user"
* Allow setting custom object class for entries
* Stop using deprecated openssl constants
2021-07-29 15:50:03 +02:00
2 changed files with 3 additions and 10 deletions

View File

@ -2,7 +2,7 @@ from sqlalchemy.exc import IntegrityError
from werkzeug.exceptions import BadRequest, NotFound
from flaschengeist.models.user import Role, Permission
from flaschengeist.database import db, case_sensitive
from flaschengeist.database import db
from flaschengeist import logger
from flaschengeist.utils.hook import Hook
@ -36,8 +36,8 @@ def update_role(role, new_name):
except IntegrityError:
logger.debug("IntegrityError: Role might still be in use", exc_info=True)
raise BadRequest("Role still in use")
else:
if role.name == new_name or db.session.query(db.exists().where(Role.name == case_sensitive(new_name))).scalar():
elif role.name != new_name:
if db.session.query(db.exists().where(Role.name == new_name)).scalar():
raise BadRequest("Name already used")
role.name = new_name
db.session.commit()

View File

@ -1,10 +1,3 @@
from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
def case_sensitive(s):
if db.session.bind.dialect.name == "mysql":
from sqlalchemy import func
return func.binary(s)
return s