【问题标题】:mod_auth_ldap mod_rewrite set username as cookiemod_auth_ldap mod_rewrite 将用户名设置为 cookie
【发布时间】:2012-02-25 00:43:45
【问题描述】:

我有一个 .htaccess 文件,它使用 mod_auth_ldap 针对 LDAP 对用户进行身份验证。我的要求是以某种方式存储他们的用户名并在其他地方使用它**。我想我可以使用 mod_rewrite 和 cookie 来做到这一点。

AuthBasicProvider ldap
AuthType Basic
AuthName "xxx"
AuthzLDAPAuthoritative off

AuthLDAPUrl "xxx" NONE
AuthLDAPBindDN "xx"
AuthLDAPBindPassword xx

Require valid-user

--

RewriteCond %{HTTP_COOKIE} !(username)
RewriteRule ^(.*)$ - [L,CO=username:%{USERNAME}:.domain.com]

如果有人想告诉我 cookie 是一个垃圾想法,并且有更好的想法,请告诉我。

非常感谢。

** 我注意到使用 cookie 中的用户名存在安全隐患,但在我的应用中这是可以接受的。

【问题讨论】:

    标签: mod-rewrite cookies


    【解决方案1】:

    魔法变量是 %{REMOTE_USER}。

    RewriteEngine on
    RewriteCond %{HTTP_COOKIE} !username
    RewriteRule ^(.*)$ - [L,CO=username:%{REMOTE_USER}:.domain.com]
    

    【讨论】:

      猜你喜欢
      • 2012-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-28
      相关资源
      最近更新 更多