小编ada*_*dam的帖子

将用户名从 apache 基本身份验证传递给cherrypy

我需要对我的应用程序的一部分使用 apache 基本身份验证。我想从 apache 获取经过身份验证的用户名,但似乎找不到访问它的位置。我可以在 apache 日志中看到用户名,所以我知道它在某处。用户通过 apache 身份验证后,请求将通过代理发送到cherrypy 服务器。

这是我的 apache vhost 配置部分:

<Location /ical>
  AuthType Basic
  AuthBasicProvider ldap
  AuthName "Example Calendar Login"
  AuthLDAPUrl "ldaps://ldap.example.net/ou=People,dc=example,dc=net?uid"
  Require valid-user

  ProxyPass http://localhost:8082/                                                                                                                                                                                                     
  ProxyPassReverse http://localhost:8082/                                                                                                                                                                                              
  SetEnv proxy-nokeepalive 1
</Location>
Run Code Online (Sandbox Code Playgroud)

用户身份验证和代理位工作正常。请求通过身份验证并发送到cherrypy后,这是我在cherrypy中的标头:

(Pdb) pp cherrypy.request.headers
{'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
 'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
 'Accept-Encoding': 'gzip,deflate',
 'Accept-Language': 'en-us,en;q=0.5',
 'Authorization': 'Basic xxxxxxxxxxx',
 'Connection': 'close',
 'Host': 'sub.example.net',
 'If-None-Match': 'e5b0879ce68fcce5b960ce4281c8d706',
 'Remote-Addr': '10.132.32.86',
 'User-Agent': 'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.10) Gecko/20100915 Ubuntu/10.04 (lucid) Firefox/3.6.10',
 'X-Forwarded-For': 'xx.xx.xx.xx, xx.xx.xx.xx',
 'X-Forwarded-Host': 'sub.example.net, sub.example.net',
 'X-Forwarded-Server': 'sub.example.net, sub'} …
Run Code Online (Sandbox Code Playgroud)

authentication cherrypy apache-2.2

6
推荐指数
2
解决办法
9373
查看次数

标签 统计

apache-2.2 ×1

authentication ×1

cherrypy ×1