我有指令
<VirtualHost *>
<Location />
AuthType Digest
AuthName "global"
AuthDigestDomain /
AuthUserFile /root/apache_users
<Limit GET>
Require valid-user
</Limit>
</Location>
WSGIScriptAlias / /some/script.wsgi
WSGIDaemonProcess mywsgi user=someuser group=somegroup processes=2 threads=25
WSGIProcessGroup mywsgi
ServerName some.example.org
</VirtualHost>
我想知道/some/script.wsgi
def application(environ, start_response):
start_response('200 OK', [
('Content-Type', 'text/plain'),
])
return ['Hello']
登录了什么用户。
我该怎么做?
答案 0 :(得分:14)
添加WSGIPassAuthorization On
:
<VirtualHost *>
<Location />
AuthType Digest
AuthName "global"
AuthDigestDomain /
AuthUserFile /root/apache_users
<Limit GET>
Require valid-user
</Limit>
</Location>
WSGIPassAuthorization On
WSGIScriptAlias / /some/script.wsgi
WSGIDaemonProcess mywsgi user=someuser group=somegroup processes=2 threads=25
WSGIProcessGroup mywsgi
ServerName some.example.org
</VirtualHost>
然后阅读environ['REMOTE_USER']
:
def application(environ, start_response):
start_response('200 OK', [
('Content-Type', 'text/plain'),
])
return ['Hello %s' % environ['REMOTE_USER']]
mod_wsgi documentation的更多信息。
答案 1 :(得分:2)
有关Apache / mod_wsgi以及访问,身份验证和授权机制的更多信息,请参阅:
http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms
默认情况下不传递信息,因为这样做可能会将密码信息泄露给可能无法获取的信息。