Flask-HTTPAuth icon indicating copy to clipboard operation
Flask-HTTPAuth copied to clipboard

Chrome is asking for password every time

Open duhd1993 opened this issue 4 years ago • 3 comments

Hello, I'm using Basic auth as provided in the tutorial example. the entry looks like

@app.route('/', methods=['GET', 'POST', 'OPTIONS', 'PUT', 'DELETE', 'HEAD', 'PATCH'])
@app.route('/<path:input_path>', methods=['GET', 'POST', 'OPTIONS', 'PUT', 'DELETE', 'HEAD', 'PATCH'])
@auth.login_required
def enter(input_path='/'):

Interestingly, firefox seems to remember the login information correctly and only asks for it once.

duhd1993 avatar Aug 24 '21 12:08 duhd1993

I'm not sure there is anything that can be done from the server side. It is up to your browser to remember credentials, so this must be a problem with your Chrome installation or its configuration.

miguelgrinberg avatar Aug 24 '21 13:08 miguelgrinberg

Hi, it's not about my Chrome installation. I've tried fresh Chrome and on different machines. It's about the web app. For the simple ones, like the hello world example, it won't ask again. But for the one I'm using, it does not work correctly on Chrome. Maybe it's because Chrome remembers password for a specific URL, not for the domain?

duhd1993 avatar Aug 24 '21 13:08 duhd1993

I'm not sure what the rules are regarding remembering credentials, but as I said, this is entirely under the control of the browser, the server cannot change those rules.

What you need to do is check if Chrome is displaying the login dialog as a result of a failed request (status code returned was 401 even though a user and password were provided), or if it displays the dialog on its own (a request without credentials was sent and responded with 401). If it is the former, then your application is rejecting the login, and this could be a bug in your code. If it is the latter, then it is Chrome deciding that given the URL, it does not have any credentials to use for it. This could be because the subdomain is different, or maybe the path, I'm not sure exactly what is the criteria for those saved credentials.

miguelgrinberg avatar Aug 24 '21 14:08 miguelgrinberg