将apache2摘要认证信息传递给mod_wsgi运行的wsgi脚本

Flo*_*sch 7 python apache authentication mod-wsgi wsgi

我有指令

<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>
Run Code Online (Sandbox Code Playgroud)

我想在/some/script.wsgi中知道

def application(environ, start_response):
    start_response('200 OK', [
        ('Content-Type', 'text/plain'),
    ])
    return ['Hello']
Run Code Online (Sandbox Code Playgroud)

用户登录的是什么

我怎么做?

nos*_*klo 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>
Run Code Online (Sandbox Code Playgroud)

然后阅读environ['REMOTE_USER']:

def application(environ, start_response):
    start_response('200 OK', [
        ('Content-Type', 'text/plain'),
    ])
    return ['Hello %s' % environ['REMOTE_USER']]
Run Code Online (Sandbox Code Playgroud)

有关mod_wsgi文档的更多信息.