我有指令
AuthType Digest AuthName "global" AuthDigestDomain / AuthUserFile /root/apache_users Require valid-user WSGIScriptAlias / /some/script.wsgi WSGIDaemonProcess mywsgi user=someuser group=somegroup processes=2 threads=25 WSGIProcessGroup mywsgi ServerName some.example.org
我想在/some/script.wsgi中知道
def application(environ, start_response): start_response('200 OK', [ ('Content-Type', 'text/plain'), ]) return ['Hello']
用户登录的是什么
我怎么做?
添加WSGIPassAuthorization On
:
AuthType Digest AuthName "global" AuthDigestDomain / AuthUserFile /root/apache_users Require valid-user WSGIPassAuthorization On WSGIScriptAlias / /some/script.wsgi WSGIDaemonProcess mywsgi user=someuser group=somegroup processes=2 threads=25 WSGIProcessGroup mywsgi ServerName some.example.org
然后阅读environ['REMOTE_USER']
:
def application(environ, start_response): start_response('200 OK', [ ('Content-Type', 'text/plain'), ]) return ['Hello %s' % environ['REMOTE_USER']]
有关mod_wsgi文档的更多信息.