fix: use constant-time comparison for tokens and consolidate admin auth #5

Merged
patillacode merged 4 commits from fix/constant-time-auth into main 2026-05-30 09:24:55 +02:00
Owner

Replace == / != with secrets.compare_digest for admin token checks and token_map lookups.
Remove duplicated verify_admin from admin router in favour of the shared require_admin dependency in auth.py.

Replace `==` / `!=` with `secrets.compare_digest` for admin token checks and `token_map` lookups. Remove duplicated `verify_admin` from admin router in favour of the shared `require_admin` dependency in `auth.py`.
fix: use constant-time comparison for tokens and consolidate admin auth
All checks were successful
CI / test (pull_request) Successful in 24s
8655a3b48b
Replace == / != with secrets.compare_digest for admin token checks and
token_map lookups. Remove duplicated verify_admin from admin router in
favour of the shared require_admin dependency in auth.py.
fix: always return 403 from require_admin regardless of token validity
Some checks failed
CI / test (pull_request) Failing after 19s
5f10148dab
Catch the 401 that get_current_user raises for unknown tokens and
re-raise as 403, so admin routes don't reveal whether a token is
recognised. Add tests covering all three cases: admin pass, unknown
token, and valid non-admin token.
fix: add 'from None' to suppress exception chaining in require_admin
All checks were successful
CI / test (pull_request) Successful in 21s
b5ca3b8a24
patillacode deleted branch fix/constant-time-auth 2026-05-31 19:41:42 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
patillacode/dropit!5
No description provided.