Updated backend auth settings
This commit is contained in:
37
test_login_fix.py
Normal file
37
test_login_fix.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""Quick smoke test: can the passwords in .env be verified? (No app imports.)"""
|
||||
import base64, hashlib, hmac, os
|
||||
from pathlib import Path
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv(Path(__file__).parent / ".env", override=True)
|
||||
|
||||
def verify_password(password, encoded):
|
||||
try:
|
||||
prefix, raw_iters, raw_salt, raw_digest = encoded.split("$")
|
||||
if prefix != "pbkdf2_sha256":
|
||||
return False
|
||||
salt = base64.b64decode(raw_salt)
|
||||
expected = base64.b64decode(raw_digest)
|
||||
iterations = int(raw_iters)
|
||||
except (ValueError, TypeError):
|
||||
return False
|
||||
candidate = hashlib.pbkdf2_hmac("sha256", password.encode("utf-8"), salt, iterations)
|
||||
return hmac.compare_digest(candidate, expected)
|
||||
|
||||
admin_hash = os.environ["AUTH_ADMIN_PASSWORD_HASH"]
|
||||
user_hash = os.environ["AUTH_USER_PASSWORD_HASH"]
|
||||
|
||||
print(f"Admin hash prefix: {admin_hash[:20]!r}")
|
||||
print(f"User hash prefix: {user_hash[:20]!r}")
|
||||
|
||||
ok1 = verify_password("DevAdmin!2026", admin_hash)
|
||||
ok2 = verify_password("DevUser!2026", user_hash)
|
||||
|
||||
print(f"Admin password verify: {ok1}")
|
||||
print(f"User password verify: {ok2}")
|
||||
|
||||
if ok1 and ok2:
|
||||
print("\nSUCCESS - both passwords verify. Login will work.")
|
||||
else:
|
||||
print("\nFAILURE - one or both passwords do NOT verify.")
|
||||
exit(1)
|
||||
Reference in New Issue
Block a user