简体   繁体   English

使用django REST进行LDAP身份验证

[英]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 目前我已经获得了访问Django REST Api后端的基本授权,我可以使用通过shell创建的username / passowrd

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. 现在我想从我的Active Directory中验证来自LDAP的用户名/密码。

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. 有什么方法我不需要为此创建登录页面,我可以在同一个地方输入用户名/密码,我的用户使用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 我是否需要创建一些获取用户名密码的手动逻辑然后定位它,我想我是否可以在不执行django已经提供的基本身份验证之类的情况下获取它

There is a package called django-auth-ldap . 有一个名为django-auth-ldap的包。 It comes with a django authentification backend. 它配备了一个django身份验证后端。 Just add django_auth_ldap.backend.LDAPBackend to your AUTHENTICATION_BACKENDS 只需将django_auth_ldap.backend.LDAPBackend添加到您的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. 您可能需要定义一些像ldap host这样的设置。 But the documentation is quite good. 但文档非常好。

Then you can use your normal authentication views and django "decide" which method to use. 然后你可以使用普通的身份验证视图和django “决定”使用哪种方法。 There is more information in the django docs django文档中有更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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