LDAP authentication with django REST

梦想的初衷 提交于 2020-01-03 08:39:30

问题


Currently I have basic authorization on for visting the Django REST Api backend and I can use the username / passowrd which was created via shell

I don't have login page for that I am using all that is built in.

Now i want to authenticate the username /password from LDAP from my Active Directory.

Is there any way that I don't need to create Login page for that and I can enter the username / password on same place and my user authenticates with Active Directory.

Do I need to create some manual logic of getting username password and then postig it, I was thinking if I can get it without doing that stuff like basic authentication which django already provides


回答1:


There is a package called django-auth-ldap. It comes with a django authentification backend. Just add django_auth_ldap.backend.LDAPBackend to your AUTHENTICATION_BACKENDS

AUTHENTICATION_BACKENDS = (
    'django_auth_ldap.backend.LDAPBackend',
    'django.contrib.auth.backends.ModelBackend',
)

You probably have to define a few more settings like you ldap host. But the documentation is quite good.

Then you can use your normal authentication views and django "decide" which method to use. There is more information in the django docs



来源:https://stackoverflow.com/questions/35550169/ldap-authentication-with-django-rest

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!