Add HMAC authentication to patron anonymization handler#11993
Merged
mekarpeles merged 5 commits intointernetarchive:masterfrom Mar 18, 2026
Merged
Add HMAC authentication to patron anonymization handler#11993mekarpeles merged 5 commits intointernetarchive:masterfrom
mekarpeles merged 5 commits intointernetarchive:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds HMAC-based authentication to the /account/anonymize handler (used for IA-triggered account anonymization) and extends the shared HMACToken.verify helper to support Unix-timestamp message formats.
Changes:
- Require
digestandmsgparameters on the account anonymization POST handler and attempt HMAC verification before processing. - Extend
HMACToken.verifywith aunix_timeoption to parse/validate expiry timestamps as Unix seconds (optionally fractional).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
openlibrary/plugins/upstream/account.py |
Adds HMAC verification inputs (digest, msg) and performs verification before anonymization. |
openlibrary/core/auth.py |
Updates HMACToken.verify to support Unix timestamps and adjusts key/timestamp parsing logic. |
890ec8b to
6bd9a64
Compare
4f92aab to
8fbbf3f
Compare
for more information, see https://pre-commit.ci
mekarpeles
pushed a commit
that referenced
this pull request
Mar 20, 2026
* Shore up HMAC token verification * Add Unix timestamp support HMAC verification method * Add HMAC authentication to anonymization handler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supports #10976
Follows #11053 #11111
Adds HMAC authentication to the patron anonymization handler. The HMAC message is expected to be colon-delimited. The expiry time must be a Unix timestamp in seconds, and may include a fraction of a second.
Handler will return different error codes, depending on what went wrong:
400 Bad Request401 Unauthorized401 Unauthorized503 Service UnavailableTechnical
Testing
Screenshot
Stakeholders