8

我有指令

<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']

什么用户登录。

我怎么做?

4

2 回答 2

15

添加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 文档

于 2008-09-23T20:08:51.840 回答
2

有关 Apache/mod_wsgi 和访问、身份验证和授权机制的其他信息,请参见:

http://code.google.com/p/modwsgi/wiki/AccessControlMechanisms

默认情况下不会传递该信息,因为这样做可能会将密码信息泄漏给可能不应该获取它的应用程序。

于 2009-06-24T12:43:03.257 回答