From 63a9b74d939b73bf7a170bc8e41cb9bdad790893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sun, 22 Sep 2013 11:29:56 +0200 Subject: Normalize usernames for LDAP. This decreases the database pollution, and increases compatibility with mockldap. --- okupy/common/auth.py | 5 +++++ 1 file changed, 5 insertions(+) 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, -- cgit v1.2.3