使用Django REST进行LDAP身份验证 [英] LDAP authentication with django REST
问题描述
当前,我具有访问Django REST Api后端的基本权限,并且可以使用通过shell
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.
现在,我想从我的Active Directory中通过LDAP验证用户名/password.
Now i want to authenticate the username /password from LDAP from my Active Directory.
有什么方法不需要为此创建登录"页面,并且可以在同一位置输入用户名/密码,并且我的用户通过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.
我是否需要创建一些手动的逻辑来获取用户名密码,然后对其进行邮寄,我在想是否可以在不进行诸如django已经提供的基本身份验证之类的工作的情况下获取它
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- auth-ldap .
它带有django身份验证后端.
只需将django_auth_ldap.backend.LDAPBackend
添加到您的AUTHENTICATION_BACKENDS
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',
)
您可能必须像ldap主机一样定义一些其他设置.但是文档非常好.
You probably have to define a few more settings like you ldap host. But the documentation is quite good.
然后,您可以使用常规的身份验证视图,并django
确定"要使用的方法. django文档中有更多信息.
Then you can use your normal authentication views and django
"decide" which method to use. There is more information in the django docs
这篇关于使用Django REST进行LDAP身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!