-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SFR-1877: rewrite URLs as fulfillment URLs #286
Merged
Merged
Conversation
This file contains 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
mitri-slory
reviewed
Feb 1, 2024
Comment on lines
+246
to
+252
if formattedEdition.get("instances"): | ||
for instance in formattedEdition['instances']: | ||
for item in instance['items']: | ||
# Map over item links and patch with pre-signed URL where necessary | ||
item['links']= list(map(APIUtils.replacePrivateLinkUrl, item['links'], repeat(request))) | ||
|
||
return formattedEdition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good way to catch item links which the presigned url should replace.
mitri-slory
approved these changes
Feb 1, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks great to me. I believe it's ready to be merged.
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.
Description
This pull request rewrites the URLs of links for objects that are not EDD links and also nypl_login required. This should cover items within the scope of Limited Access.
Other options (like rewriting the links in the database and referring to a third, new column of S3 urls) were considered, but none of them seemed like they would work without heavily rewriting some of the code related to FRBRized output.
As it stands, almost all of the work is done at the "Format..." level for each hierarchy where links are part of the JSON formatted output. While this makes the change fairly superficial and it must be implemented in many places, it is hopefully transparent enough that this link overwriting can be easily found and modified and/or removed later if needed.
Motivation and Context
The link URLs in the database represent private s3 URLs. If the s3 URLs are sent as part of the JSON, there won't be any way for users (or the front end) to retrieve the contents of the URLs. The fulfill endpoint already contains the logic needed to generate a fulfill URL that points to the private item bucket via a time-gated URL that requires user authentication; however, the private URLs to s3 must be rewritten with these fulfillment URLs before the API output is returned.