Django Multiple Authentication Backend for one project, HOW?

后端 未结 4 1842
野性不改
野性不改 2020-12-05 00:52

Need serious help here.

I have an application written in django/python and I have to extend it and include some other solution as an \"app\" in this application. For

4条回答
  •  执念已碎
    2020-12-05 01:28

    Using multiple backend authentications is as simple as pie. You just need to understand the workflow of Django apps.

    AUTHENTICATION_BACKENDS = (
        'django.contrib.auth.backends.Backend1',
        'django_openid_auth.auth.Backend2',
        )
    

    For example you have the following two backends defined. Django will first go to the first backend and you just need to put some logic in that backend so that, if its not related to that backend it get forwarded to the other backend or returned without any results. In case of no results django will automatically shift the request from first backend to the second and if available third one. I spend a lot of time on this and found out that it was not that complex.

提交回复
热议问题