I\'m developing a web page using Flask, on an Apache server where the Server is enforcing basic authentication. That is, a user accessing a page on the server is presented with
You can find authentication information in Flask from the request
object.
from flask import request
def my_view():
auth = request.authentication
username = auth.username
password = auth.password
...
Note however that if you're using apache mod_wsgi, you'll need to turn on the WSGIPassAuthorization
directive in your virtualhost config. Otherwise apache will consume the authentication header and won't pass it to the WSGI layers.
...
WSGIPassAuthorization On
...
more info here and here.