有没有办法从 Apache2 配置中的 HTTP 授权标头获取密码?
我发现我可以通过以下代码访问 HTTP 授权标头,
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
不幸的是我不明白如何从 base64 对其进行解码,然后拆分用户名和密码。
当然,在 apache 配置之外执行此操作非常容易,但我需要配置内的用户名和密码才能将它们传递到 LDAP 授权模块。
实际上我想做这样的事情:
<Directory "C:/my/directory">
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
AuthType Basic
AuthName "Trac"
AuthBasicProvider "ldap"
AuthLDAPURL "ldap://domain.local:3268/DC=domain,DC=local?sAMAccountName?sub?> (objectClass=user)"
AuthLDAPBindDN %{HTTP_USER}@domain.local
AuthLDAPBindPassword %{HTTP_PASSWORD}
AuthzLDAPAuthoritative off
Require valid-user
</Directory>
我需要这个,因为我们的 LDAP 服务器不接受匿名请求。
I've found that I can access HTTP Authorization header by the following code
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
Unfortunately I don't understand how to decode it from base64 and then split username and password.
Of course it's very easy to do this outside apache config, but I need user name and password inside the config in order to pass them to LDAP authorization module.
Actually I want to do something like this:
<Directory "C:/my/directory">
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
AuthType Basic
AuthName "Trac"
AuthBasicProvider "ldap"
AuthLDAPURL "ldap://domain.local:3268/DC=domain,DC=local?sAMAccountName?sub?> (objectClass=user)"
AuthLDAPBindDN %{HTTP_USER}@domain.local
AuthLDAPBindPassword %{HTTP_PASSWORD}
AuthzLDAPAuthoritative off
Require valid-user
</Directory>
I need this because our LDAP server doesn't accept anonymous requests.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,您应该创建专用的 LDAP 用户进行授权。
与 HTTP_AUTHORIZATION 标头相关,请检查 RFC2617 http://www.ietf.org/rfc/rfc2617.txt< /a>
这取决于您使用的身份验证方案。从 BASIC 方案您可以解码用户名和密码,但从其他方案可能无法解码(NTLM)。
Basically, you should create dedicated LDAP user for authorization.
Related to HTTP_AUTHORIZATION header, check RFC2617 http://www.ietf.org/rfc/rfc2617.txt
It depends on which auth scheme you are using.From BASIC scheme you can decode USERNAME and PASSWORD, but from other maybe not possible (NTLM).