Here's a small Flask app authenticated with Flask-HTTPAuth
.
How to pass an argument (such as authentication on/off flag, or verbosity level / debug on/off flag) to a function (such as authenticate
below) decorated with @auth.verify_password
(without raising an error)?
Current code:
auth = HTTPBasicAuth()authorized_users_dict = [..]# [..]@auth.verify_password
def authenticate(username, password): if username in authorized_users_dict:if check_password_hash(pwhash=authorized_users_dict[username], password=password):return True# [..]# [..]@auth.login_required()# [..]