diff --git a/deps/ldapalchemy b/deps/ldapalchemy index e223f1617e3452d66d20b9368a74d2bdf6cc1ba4..6a0b85f2c6a11951d99d4b4e84b1df992580d964 160000 --- a/deps/ldapalchemy +++ b/deps/ldapalchemy @@ -1 +1 @@ -Subproject commit e223f1617e3452d66d20b9368a74d2bdf6cc1ba4 +Subproject commit 6a0b85f2c6a11951d99d4b4e84b1df992580d964 diff --git a/uffd/default_config.cfg b/uffd/default_config.cfg index 95f0934817c38f404b93d8f79e465758403fbffb..b4c84145d59710d74079da3f5140f07108f11ff9 100644 --- a/uffd/default_config.cfg +++ b/uffd/default_config.cfg @@ -2,11 +2,23 @@ LDAP_BASE_USER="ou=users,dc=example,dc=com" LDAP_BASE_GROUPS="ou=groups,dc=example,dc=com" LDAP_BASE_MAIL="ou=postfix,dc=example,dc=com" +LDAP_FILTER_USER=[("objectClass","person")] +LDAP_FILTER_GROUP=[("objectClass","groupOfUniqueNames")] +LDAP_FILTER_MAIL=[("objectClass","postfixVirtual")] + LDAP_SERVICE_BIND_DN="" LDAP_SERVICE_BIND_PASSWORD="" LDAP_SERVICE_URL="ldapi:///" +LDAP_SERVICE_USE_STARTTLS=True LDAP_USER_OBJECTCLASSES=["top", "inetOrgPerson", "organizationalPerson", "person", "posixAccount"] +LDAP_USER_ATTRIBUTE_UID="uidNumber" +LDAP_USER_ATTRIBUTE_DISPLAYNAME="cn" +LDAP_USER_ATTRIBUTE_MAIL="mail" +# The User class gets filled by which LDAP attribute and to type (single/list) +LDAP_USER_ATTRIBUTE_EXTRA={ +#"phone": {"type": "single", "name": "mobile"}, +} LDAP_USER_GID=20001 LDAP_USER_MIN_UID=10000 LDAP_USER_MAX_UID=18999 diff --git a/uffd/mail/models.py b/uffd/mail/models.py index 322af9d487d4bf71443d3af59e5f57e8f84a6963..73f998c2c99fed691e2e494f7dc4b81003e0fa93 100644 --- a/uffd/mail/models.py +++ b/uffd/mail/models.py @@ -3,7 +3,7 @@ from uffd.lazyconfig import lazyconfig_str, lazyconfig_list class Mail(ldap.Model): ldap_search_base = lazyconfig_str('LDAP_BASE_MAIL') - ldap_filter_params = (('objectClass', 'postfixVirtual'),) + ldap_filter_params = lazyconfig_list('LDAP_FILTER_MAIL') ldap_object_classes = lazyconfig_list('MAIL_LDAP_OBJECTCLASSES') ldap_dn_attribute = 'uid' ldap_dn_base = lazyconfig_str('LDAP_BASE_MAIL') diff --git a/uffd/user/models.py b/uffd/user/models.py index 51dfe8271146714b2928055cb98681ef6d136541..7808a184b65c9a87cbc8c955f19a78d2d8db19bf 100644 --- a/uffd/user/models.py +++ b/uffd/user/models.py @@ -19,15 +19,15 @@ def get_next_uid(): class User(ldap.Model): ldap_search_base = lazyconfig_str('LDAP_BASE_USER') - ldap_filter_params = (('objectClass', 'person'),) + ldap_filter_params = lazyconfig_list('LDAP_FILTER_USER') ldap_object_classes = lazyconfig_list('LDAP_USER_OBJECTCLASSES') ldap_dn_base = lazyconfig_str('LDAP_BASE_USER') ldap_dn_attribute = 'uid' - uid = ldap.Attribute('uidNumber', default=get_next_uid) + uid = ldap.Attribute(lazyconfig_str('LDAP_USER_ATTRIBUTE_UID'), default=get_next_uid) loginname = ldap.Attribute('uid') - displayname = ldap.Attribute('cn', aliases=['givenName', 'displayName']) - mail = ldap.Attribute('mail') + displayname = ldap.Attribute(lazyconfig_str('LDAP_USER_ATTRIBUTE_DISPLAYNAME'), aliases=['givenName', 'displayName']) + mail = ldap.Attribute(lazyconfig_str('LDAP_USER_ATTRIBUTE_MAIL')) pwhash = ldap.Attribute('userPassword', default=lambda: hashed(HASHED_SALTED_SHA512, secrets.token_hex(128))) groups = [] # Shuts up pylint, overwritten by back-reference @@ -103,7 +103,7 @@ class User(ldap.Model): class Group(ldap.Model): ldap_search_base = lazyconfig_str('LDAP_BASE_GROUPS') - ldap_filter_params = (('objectClass', 'groupOfUniqueNames'),) + ldap_filter_params = lazyconfig_list('LDAP_FILTER_GROUP') gid = ldap.Attribute('gidNumber') name = ldap.Attribute('cn')