LDAP authentication with django REST

2019-06-20 02:11发布

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条回答
聊天终结者
2楼-- · 2019-06-20 02:39

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

查看更多
登录 后发表回答