From 5d22f5ee0a576d71998536ec0bd2eb9d431012bc Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Tue, 13 Oct 2015 16:57:38 -0400 Subject: [PATCH] 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. --- zproject/backends.py | 4 ++-- zproject/local_settings_template.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/zproject/backends.py b/zproject/backends.py index b1368774c1..e154803205 100644 --- a/zproject/backends.py +++ b/zproject/backends.py @@ -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 diff --git a/zproject/local_settings_template.py b/zproject/local_settings_template.py index 5d6850b866..c4f0d02087 100644 --- a/zproject/local_settings_template.py +++ b/zproject/local_settings_template.py @@ -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 = {