miguelgrinberg / Flask-HTTPAuth

Simple extension that provides Basic, Digest and Token HTTP authentication for Flask routes
MIT License
1.27k stars 228 forks source link

call decorated verify_password #101

Closed yan-hic closed 4 years ago

yan-hic commented 4 years ago

Considering

    @auth.verify_password
    def authenticate(username, password):

We use flask as a proxy to a 3rd party website, and HTTPBasicAuth() to capture the credentials to pass on to the logon page and get the cookies (with requests).

Sometimes the target website abruptly closes the connection/session and we need to re-authenticate, which we initially do in authenticate()

Is there a way to force for a re-authentication or call authenticate() from another function without passing the authenticated password ?

If not, I rather not store the user password in g or in flask's session but had hoped auth.get_password()` or similar would return it.

miguelgrinberg commented 4 years ago

The username and password are already stored in the request object.

yan-hic commented 4 years ago

oh, didn't know that ! So a authenticate(request.authorization.username, request.authorization.password) will just do. Thanks !