Clean a CAS-returned username

cas.eleves.ens.fr allows users such as '  FooBAr ' or 'foobar' in
indifferently
This commit is contained in:
Théophile Bastian 2017-10-14 16:57:59 +02:00
parent 17e71451fe
commit b1727f7e07
2 changed files with 8 additions and 1 deletions

View file

@ -87,7 +87,7 @@ AUTH_PASSWORD_VALIDATORS = [
AUTHENTICATION_BACKENDS = [
'django.contrib.auth.backends.ModelBackend',
'django_cas_ng.backends.CASBackend',
'mainsite.cas_backend.BOcalCASBackend',
]
CAS_ADMIN_PREFIX = '/yaes5eiS' # we don't want CAS to take over /admin auth

7
mainsite/cas_backend.py Normal file
View file

@ -0,0 +1,7 @@
from django_cas_ng.backends import CASBackend
class BOcalCASBackend(CASBackend):
# Partly from Robin Champenois's "ExperiENS". Thanks!
def clean_username(self, username):
return username.lower().strip()