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, staffuserbackend returns user object , we're done.
  • if user not staff, credentials checked against modelbackend.
  • if credentials valid standard user, modelbackend returns user object , user authenticated usual.
  • if credentials not accepted backend, authentication fails.

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -