Django 中的 Ntlm/Kerberos 身份验证
我正在寻找有关将 Windows 身份验证支持添加到 django 应用程序中的指南,特别是 OSQA
我知道 http://code.google.com/p/python-ntlm/ 还看到了这篇文章: http://erny-rev .blogspot.com/2007/11/ntlm-authentication-in-django.html 但我不是Django开发者,我只想在Windows环境中部署OSQA(内网,所以我需要添加Windows身份验证)。所以我正在寻找简单的分步描述。
(我已经设法使用 SQL Server 在 Windows 上部署 OSQA 站点,并且它正在工作)
更新:
我不仅希望获得针对 AD 的身份验证,还希望在 IE 中获得类似 SSO 的行为。当用户在 IE 中访问我的基于 django 的站点时,它会自动使用其域帐户进行身份验证。
I'm looking for a guide about adding windows authentication support into a django app, particulary OSQA
I'm aware about http://code.google.com/p/python-ntlm/
And also saw this post: http://erny-rev.blogspot.com/2007/11/ntlm-authentication-in-django.html
But I'm not a Django-dev, I just want to deploy OSQA in Windows enviroment (intranet, so I need to add windows authentication). So I'm looking for simple step-by-step description.
(I've managed to deploy a OSQA site on windows with SQL Server and it's working)
UPDATE:
I'd like to get not just auth against AD but SSO-like behavior in IE. As a user access my django-based site in IE it'd automaticaly authenticated with its domain account.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用 Apache、mod_auth_kerb 和 REMOTE_USER 身份验证以及托管为 mod_wsgi 的 Django 来完成此操作。
这是我们使用的一些配置的示例:
然后您需要进行设置:
http://docs.djangoproject.com/en/dev/howto/auth-remote-user/
需要注意的几个警告:
希望这有帮助。
You can do this using Apache, mod_auth_kerb and REMOTE_USER authentication with Django hosted as mod_wsgi.
Here is an example of some config we use:
You then need to setup this:
http://docs.djangoproject.com/en/dev/howto/auth-remote-user/
A couple of caveats to note:
Hope this helps.
这可能不是那么优雅,但它有效(导入/放入视图中):
用法:
我确信这可以作为装饰器变得更加优雅,并且可能还有其他方法 - 但我已经使用了它并且它有效。
This might not be that elegant, but it works (import/put into views):
Usage:
I am sure this could be made more elegant as a decorator, and there may be other ways - but I've used it and it works.
通常,如果您只想针对 Active Directory 进行身份验证,最有可能成功的方法是针对 Active Directory LDAP 服务使用 LDAP 身份验证。唯一的技巧是,与大多数 LDAP 服务器不同,Active Directory 需要有经过身份验证的用户(和密码)。大多数人最终都会建立一个“ldap-query”用户,并对该用户进行硬编码以进行查询配置。
有关示例,请参阅 http://djangosnippets.org/snippets/501/ 和 http://www.google.com/search?q=Django+LDAP+身份验证
Generally, if you just want authentication against Active Directory, the approach most likely to succeed is to use LDAP authentication against the Active Directory LDAP service. The only trick is that unlike most LDAP servers, Active Directory needs to have an authenticated user (and password). Most folks end up establishing a 'ldap-query' user with and hardcode that user for the query configuration.
For examples, see http://djangosnippets.org/snippets/501/ and http://www.google.com/search?q=Django+LDAP+authentication