SEAB-7134: Fix auth-related 500 #6106
Merged
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 PR fixes a
NullPointerExceptiondue to a missing null check inSamPermissionsImpl.canDoAction. The exception is thrown when an unauthenticated request is made to the Zip generation endpoint for an unpublished HOSTED workflow. We get there becauseWorkflowResourceoverridescanReadto add the permissionsImpl (SAM) checks, wherein the flaw is located.Note that you can't reproduce this on qa, and that the problem only happens for HOSTED workflows.
How did the user trigger this? Per the logs, my best theory is that the user had copied the download link from the UI, and, days later, pasted it into their browser. We can tell that the user wasn't using the dockstore UI when the 500 occurred, because in the logged diagnostic info, the
x-session-id-fingerprintisnull.I suspect that this PR also fixes https://ucsc-cgl.atlassian.net/browse/SEAB-6939
For some still-valid (IMHO) recommendations about the architecture of the auth code, see the longest paragraph in this PR description (of yore):
#4989
Review Instructions
On staging, via the API, try to download a Zip for an unpublished HOSTED workflow, as an unauthenticated user (no token), and confirm that you get a proper non-500 error response.
Issue
https://ucsc-cgl.atlassian.net/browse/SEAB-7134
Security and Privacy
If there are any concerns that require extra attention from the security team, highlight them here and check the box when complete.
e.g. Does this change...
Please make sure that you've checked the following before submitting your pull request. Thanks!
mvn clean install@RolesAllowedannotation