[verified] fix(auth): support Unicode credentials

This commit is contained in:
2026-10-04 03:53:47 +00:00
parent 755c26865c
commit d84ed8ff2a
4 changed files with 79 additions and 6 deletions
+2
View File
@@ -104,6 +104,8 @@ async def login(request: Request) -> Response:
keep_blank_values=True,
strict_parsing=True,
max_num_fields=3,
encoding="utf-8",
errors="strict",
)
except (UnicodeDecodeError, ValueError):
authentication.log_auth_event("login_request_rejected", correlation_id)
+6 -2
View File
@@ -113,8 +113,12 @@ def verify_credentials(
) -> bool:
if not isinstance(submitted_id, str) or not isinstance(submitted_password, str):
return False
id_matches = hmac.compare_digest(submitted_id, credentials.admin_id)
password_matches = hmac.compare_digest(submitted_password, credentials.password)
id_matches = hmac.compare_digest(
submitted_id.encode("utf-8"), credentials.admin_id.encode("utf-8")
)
password_matches = hmac.compare_digest(
submitted_password.encode("utf-8"), credentials.password.encode("utf-8")
)
return id_matches and password_matches