TDD: 1, Me: 0

This commit is contained in:
2024-12-13 18:08:44 +02:00
commit 9c1cfa7c23
36 changed files with 2374 additions and 0 deletions

18
app/auth.py Normal file
View 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