[verified] fix(auth): support Unicode credentials
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user