TDD: 1, Me: 0
This commit is contained in:
18
app/auth.py
Normal file
18
app/auth.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from flask_httpauth import HTTPBasicAuth
|
||||
from werkzeug.security import check_password_hash
|
||||
from flask import current_app as app # Using the current Flask app context
|
||||
|
||||
auth = HTTPBasicAuth()
|
||||
|
||||
# Initialize the users dictionary once
|
||||
users = {}
|
||||
|
||||
@auth.verify_password
|
||||
def verify_password(username, password):
|
||||
global users # Ensure we're modifying the global users dictionary
|
||||
if not users: # Only populate the dictionary if it's empty
|
||||
users = {
|
||||
"anon": app.config['USER_PASS_HASH']
|
||||
}
|
||||
if username in users and check_password_hash(users.get(username), password):
|
||||
return username
|
||||
Reference in New Issue
Block a user