Django Multiple Authentication Backends Based On Status -
i wondering how tell django authentication backend use based on if user marked staff or if not.
can done?
since authentication backend used django user object, not known @ time we're calling backend wether user marked staff or not.
is still possible use different backends staff , non-staff user, chaining backends explained in specifying authentication backends. example if settings are:
authentication_backend = ( 'myapp.auth.staffuserbackend', 'django.contrib.auth.backends.modelbackend', ) where myapp.auth.staffuserbackend recognizes staff users, happen when user authenticates:
- the credentials checked against
staffuserbackend. - if user staff , credentials correct,
staffuserbackendreturns user object , we're done. - if user not staff, credentials checked against
modelbackend. - if credentials valid standard user,
modelbackendreturnsuserobject , user authenticated usual. - if credentials not accepted backend, authentication fails.
Comments
Post a Comment