-
-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTPDigestAuth raise TypeError when get_password() returns None. #5
Comments
Thanks. I have updated the docs to use |
Hi. I don't think 051195d is going to fix anything. We could test with this sample script: from flask import Flask
from flask.ext.httpauth import HTTPDigestAuth
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret key here'
auth = HTTPDigestAuth()
users = {
"john": "hello",
"susan": "bye"
}
@auth.get_password
def get_pw(username):
if username in users:
return users.get(username) # this is equivalent to users[username] in this context anyway.
return None
@app.route('/')
@auth.login_required
def index():
return "Hello, %s!" % auth.username()
if __name__ == '__main__':
app.run() If we login with a known user name and wrong password e.g. The real problem is that, in lines 49–52 of password = self.get_password_callback(auth.username)
#if not password:
# return self.auth_error_callback()
if not self.authenticate(auth, password): when the user name is invalid, a1 = auth.username + ":" + auth.realm + ":" + password where |
Okay, I've finally understood the problem, and (of course) you were correct. I have fixed this and added a test for this specific condition. Thanks! |
Hi, I'm probing the same example (https://github.com/miguelgrinberg/Flask-HTTPAuth#digest-authentication-example), but I always get an "Unathorized Access" when I make a request. Example:
What am I doing wrong? |
The digest module requires session storage. In the default configuration Miguel ----- Original Message -----
Required",nonce="bd371cbdb5f144d8dcfb9557bb1de941",opaque="fe97f3f602eabfad9fbb186ca5cabb7f"
session=.eJwly00OQDAQBtC7zNpC6Y-6jMw304lVS8JK3B2xf-8iPo91qa1KoZmgY3ICRTDnvU4qhhxCApyW7B11v28b7-cXrORko8V-KAxjzfbSKQoHYSAZ3Q8Qyh8v.BoIgfQ.HJZG1TN4BE4J_G5-XUayEnzDKOQ;
Required",nonce="e853310af9d60336b41337e274f3f945",opaque="dd4e81a2f44b91b0d875a86d8c50db7d"
session=.eJwlyzEOgCAMAMC_dHYAWqD4GVMoxAk0kcn4d2Pc726Qee1bH71UWKGyR7RGWtJgEEMmixiri9SwJfKw_H4ccs4vqFJlK64R5WSzUY5eOCgXbzRHhecFl8EclA.BoIgfQ.6btCp7oBk4w28CqZ5BhWO2C45PI;
|
Hi, |
I don't have an example ready, but you can look at the unit test code for an example app. To use curl you do the same thing you do for basic auth, but add |
If we implement
@auth.get_password
as described in the doc:When the user logs in with an invalid user name, the script with raise an error:
(BTW the test suite does not catch this because it simply makes every invalid user's password being
'other'
. This is totally wrong, and should return some non-string to indicate unconditional rejection.)The text was updated successfully, but these errors were encountered: