Building a custom authentication backend
Django allows you to authenticate users against different sources. The AUTHENTICATION_BACKENDS
setting includes a list of authentication backends available in the project. The default value of this setting is the following:
['django.contrib.auth.backends.ModelBackend']
The default ModelBackend
authenticates users against the database using the User
model of django.contrib.auth
. This is suitable for most web projects. However, you can create custom backends to authenticate your users against other sources, such as a Lightweight Directory Access Protocol (LDAP) directory or any other system.
You can read more information about customizing authentication at https://docs.djangoproject.com/en/4.1/topics/auth/customizing/#other-authentication-sources.
Whenever the authenticate()
function of django.contrib.auth
is used, Django tries to authenticate the user against each of the backends defined in AUTHENTICATION_BACKENDS
...