Passage des informations d'authentification digest apache2 à un script wsgi exécuté par mod_wsgi

StackOverflow https://stackoverflow.com/questions/123499

Question

J'ai la directive

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

J'aimerais savoir dans /some/script.wsgi

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

Quel utilisateur est connecté?

Comment je fais ça?

Était-ce utile?

La solution

ajouter WSGIPassAuthorization sur :

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

Il suffit ensuite de lire environ ['REMOTE_USER'] :

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

Plus d'informations sur documentation de mod_wsgi .

Autres conseils

Des informations supplémentaires sur Apache / mod_wsgi et les mécanismes d'accès, d'authentification et d'autorisation sont disponibles dans:

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

Les informations ne sont pas transmises par défaut, car cela pourrait entraîner la divulgation d'informations sur les mots de passe aux applications qui ne devraient peut-être pas les obtenir.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top