
Besoin d’une authentification LDAP ? Hop, un article à lire
.
Dans un fichier your_project/your_app/backends.py:
from django.contrib.auth.models import User
from django.contrib.auth.backends import ModelBackend as DjangoModelBackend
class ModelBackend(DjangoModelBackend):
def authenticate(self, username=None, password=None):
""" Case insensitive username """
try:
user = User.objects.get(username__iexact=username)
if user.check_password(password):
return user
except User.DoesNotExist:
return None
Dans le fichier settings.py:
# Custom Auth Backend : case insensitive username
AUTHENTICATION_BACKENDS = (
'your_project.your_app.backends.ModelBackend',
)
... Lire le code ! django/contrib/auth/__init__.py
| Author: | Lauréline Guérin |
|---|---|
| Contact: | laureline.guerin_at_makina-corpus.org |
| LastUpdate: | 07/06/2008 |