Allow Preview User to download files without requiring a Guestbook Re…#12548
Allow Preview User to download files without requiring a Guestbook Re…#12548stevenwinship wants to merge 5 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bdf4a83 to
1511464
Compare
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
qqmyers
left a comment
There was a problem hiding this comment.
This looks like it would work, except for some minor URL tweaking, but it seems like the fixes are in one-off places rather than the way things are done for other types of users. I made some comments about moving things around and avoiding a new method using signing.
| } else { | ||
| logger.fine("Redirecting to file download url: " + fileDownloadUrl); | ||
| try { | ||
| // Sign URL for preview url user |
There was a problem hiding this comment.
Now that you set the token in the PrivateUrlUser, is there any reason you can't generate the required signed URL in the same method, e.g.
dataverse/src/main/java/edu/harvard/iq/dataverse/api/Access.java
Lines 584 to 608 in 72a5ad2
There was a problem hiding this comment.
I'm not fully understanding your comment. The signing happens in 2 places.
- in DatasetPage (FileDownloadServiceBean) when the preview user tries to download a file. The redirect is simply "/api/access/..." (no scheme, service, port)
- In access when the api call comes in. the url is "http://localhost:8080/api/v1/access/..."
When the access call compares the token hash of the signed url it doesn't match if the signed token was generated using "/api/access/..."
There was a problem hiding this comment.
Perhaps I'm misunderstanding. My assumption is that this case is similar to the case of a dataset creator downloading from the draft - just a different type of user and different key. So I expected to see some code right where signing for an authenticated user happened to also sign for a privateUulUser - same url, same signing code, just a difference in getting the signing key for this case - versus a new method to generate and sign a URL for this case.
There was a problem hiding this comment.
The dataset creator downloading from draft includes the auth key in the header. The preview user has a token in the query params. in order to propagate the fact that it's a preview user and not a guest the url needs to be signed. This allows the SignedUrlAuthMechanism to authenticate a PrivateUrlUser based on the user=!{datasetId} and the token from the datasetId
| @@ -0,0 +1,2 @@ | |||
| ## Bug ## | |||
| Preview Users can now download files without the required guestbook response. | |||
There was a problem hiding this comment.
Preview URL users could not download files from the dataset being previewed if a guestbook was assigned to that dataset. This is now fixed.
| } | ||
| if(!sessionUserCanViewUnpublishedDataset){ | ||
| //Only Reset if user cannot view this Draft Version | ||
| privateUrlUser.setToken(token); |
There was a problem hiding this comment.
Would it be cleaner to set this in
- when the token lookup is done?
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
8a7ea00 to
4477597
Compare
This comment has been minimized.
This comment has been minimized.
1 similar comment
|
📦 Pushed preview images as 🚢 See on GHCR. Use by referencing with full name as printed above, mind the registry name. |
The guestbook popup does not appear to collect a response before the download attempt is made. Disabling the guestbook on the dataset resolves the issue and files download normally through the Preview URL. This fix reinstates the behavior of the JSF UI from prior versions of Dataverse.
Which issue(s) this PR closes:#12535
Special notes for your reviewer:
Suggestions on how to test this: Create a dataset with a guestbook. Generate a Preview URL. Using the preview url try to download files and dataset zip file. This should work without requiring the guestbook response.
Does this PR introduce a user interface change? If mockups are available, please link/include them here:
Is there a release notes update needed for this change?: Included
Additional documentation: