diff --git a/authens/backends.py b/authens/backends.py index ebea500..e5719e3 100644 --- a/authens/backends.py +++ b/authens/backends.py @@ -52,14 +52,18 @@ class ENSCASBackend: def authenticate(self, request, ticket=None): cas_client = get_cas_client(request) - uid, attributes, _ = cas_client.verify_ticket(ticket) + cas_login, attributes, _ = cas_client.verify_ticket(ticket) - if not uid: + if cas_login is None: # Authentication failed return None + cas_login = self.clean_cas_login(cas_login) year = get_entrance_year(attributes) - return self._get_or_create(uid, year) + return self._get_or_create(cas_login, year) + + def clean_cas_login(self, cas_login): + return cas_login.strip().lower() def get_free_username(self, cas_login): """Find an available username for a new user.