aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2013-09-22 11:29:56 +0200
committerMichał Górny <mgorny@gentoo.org>2013-09-22 11:30:25 +0200
commit63a9b74d939b73bf7a170bc8e41cb9bdad790893 (patch)
tree259469ae14314c3e8a8502e6efd640048ebf3272
parentClean up django_auth_ldap leftovers. (diff)
downloadidentity.gentoo.org-63a9b74d939b73bf7a170bc8e41cb9bdad790893.tar.gz
identity.gentoo.org-63a9b74d939b73bf7a170bc8e41cb9bdad790893.tar.bz2
identity.gentoo.org-63a9b74d939b73bf7a170bc8e41cb9bdad790893.zip
Normalize usernames for LDAP.
This decreases the database pollution, and increases compatibility with mockldap.
-rw-r--r--okupy/common/auth.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/okupy/common/auth.py b/okupy/common/auth.py
index 08d2fe6..9dcf554 100644
--- a/okupy/common/auth.py
+++ b/okupy/common/auth.py
@@ -23,6 +23,11 @@ class LDAPAuthBackend(ModelBackend):
"""
def authenticate(self, request, username, password):
+ # LDAP is case- and whitespace-insensitive
+ # we do normalization to avoid duplicate django db entries
+ # and help mockldap
+ username = username.lower().strip()
+
try:
bound_ldapuser = get_bound_ldapuser(
request=request,