Add handler to associate IA ocaids with OL edition records#12429
Add handler to associate IA ocaids with OL edition records#12429jimchamp wants to merge 9 commits intointernetarchive:masterfrom
ocaids with OL edition records#12429Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new internal API endpoint intended to let Internet Archive associate an IA ocaid with an Open Library edition record.
Changes:
- Introduces a new
POST /api/link(JSON) handler to validate an HMAC token + expiry and then update an edition record. - Updates the target edition’s
ocaidand appends ania:{ocaid}entry tosource_records.
| i = web.input(digest="", msg="") | ||
| digest = i.digest | ||
| msg = i.msg | ||
|
|
There was a problem hiding this comment.
PR description says digest is a SHA-256 hash of msg, but this endpoint uses HMACToken.verify, which expects an HMAC using a shared secret (and currently MD5-based). Please align the PR description and the IA client implementation with what the server actually verifies.
There was a problem hiding this comment.
HMAC.verify has been updated to use sha256 in #12402.
| class link_ia_ol(delegate.page): | ||
| path = "/api/link" | ||
| encoding = "json" | ||
|
|
||
| def POST(self): |
There was a problem hiding this comment.
This adds a new /api/link handler with multiple behaviors (401/400/404/500 + a successful update to ocaid/source_records), but there are no tests covering it. Please add unit tests following existing openlibrary/plugins/openlibrary/tests/* patterns to assert the expected status codes and that edition fields are updated correctly.
|
@jimchamp This should not add an archive.org |
|
Thanks @hornc! I had already forgotten to ask about that assumption... Will update shortly. |
2274ad7 to
05793a6
Compare
Closes #11490
Creates new
/api/link.jsonhandler for the purpose of syncing data between IA and OL.POSTrequests to this endpoint are expected to have the following query parameters:msg: A colon delimited string in the format{ocaid}|{openlibrary_edition_id}|{expiry}digest: The sha256 hashed value ofmsgAll inputs required for the operation are expected to be sent in the
msgstring.The
POSThandler will, in order:digestand check the expirymsgocaidto the OL editionPossible responses:
exception_message"}Technical
Testing
Screenshot
Stakeholders