Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 438
John Kaff Avatar asked Feb 22 '16 09:02

John Kaff


1 Answers

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

like image 187
ilse2005 Avatar answered Oct 22 '22 18:10

ilse2005