Admin login pasword changes
This commit is contained in:
@@ -6,6 +6,9 @@ from dotenv import load_dotenv
|
||||
load_dotenv(Path(__file__).parent / ".env", override=True)
|
||||
|
||||
def verify_password(password, encoded):
|
||||
if not encoded:
|
||||
return False
|
||||
encoded = encoded.strip().strip("'\"")
|
||||
try:
|
||||
prefix, raw_iters, raw_salt, raw_digest = encoded.split("$")
|
||||
if prefix != "pbkdf2_sha256":
|
||||
@@ -18,20 +21,23 @@ def verify_password(password, encoded):
|
||||
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"]
|
||||
admin_hash = os.environ.get("AUTH_ADMIN_PASSWORD_HASH", "").strip().strip("'\"")
|
||||
user_hash = os.environ.get("AUTH_USER_PASSWORD_HASH", "").strip().strip("'\"")
|
||||
|
||||
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)
|
||||
ok1 = verify_password("admin123", admin_hash)
|
||||
ok2 = verify_password("DevUser!2026", user_hash) if user_hash else True
|
||||
|
||||
print(f"Admin password verify: {ok1}")
|
||||
print(f"User password verify: {ok2}")
|
||||
print(f"Admin password ('admin123') verify: {ok1}")
|
||||
if user_hash:
|
||||
print(f"User password ('DevUser!2026') verify: {ok2}")
|
||||
else:
|
||||
print("User account is optional / unset.")
|
||||
|
||||
if ok1 and ok2:
|
||||
print("\nSUCCESS - both passwords verify. Login will work.")
|
||||
print("\nSUCCESS - admin password verifies cleanly. Login will work.")
|
||||
else:
|
||||
print("\nFAILURE - one or both passwords do NOT verify.")
|
||||
print("\nFAILURE - password verification failed.")
|
||||
exit(1)
|
||||
|
||||
Reference in New Issue
Block a user