Improve LDAP_APPEND_DOMAIN default.

The documentation suggests the default is None; this change makes that
true.  Also make the actual code robust to this being set to "" instead.
This commit is contained in:
Tim Abbott 2015-10-13 16:57:38 -04:00
parent 71a06d58de
commit 5d22f5ee0a
2 changed files with 3 additions and 3 deletions

View File

@ -145,13 +145,13 @@ class ZulipLDAPAuthBackendBase(ZulipAuthMixin, LDAPBackend):
return set()
def django_to_ldap_username(self, username):
if settings.LDAP_APPEND_DOMAIN is not None:
if settings.LDAP_APPEND_DOMAIN:
if not username.endswith("@" + settings.LDAP_APPEND_DOMAIN):
raise ZulipLDAPException("Username does not match LDAP domain.")
return email_to_username(username)
return username
def ldap_to_django_username(self, username):
if settings.LDAP_APPEND_DOMAIN is not None:
if settings.LDAP_APPEND_DOMAIN:
return "@".join((username, settings.LDAP_APPEND_DOMAIN))
return username

View File

@ -250,7 +250,7 @@ AUTH_LDAP_USER_SEARCH = LDAPSearch("ou=users,dc=example,dc=com",
# If the value of a user's "uid" (or similar) property is not their email
# address, specify the domain to append here.
LDAP_APPEND_DOMAIN = ADMIN_DOMAIN
LDAP_APPEND_DOMAIN = None
# This map defines how to populate attributes of a Zulip user from LDAP.
AUTH_LDAP_USER_ATTR_MAP = {