简体   繁体   中英

LDAP authentication with django REST

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM