Repository navigation
CLARIN-DSpace v9/Deny reads of ownerless CLARIN user records and anonymous CLARIN searches - #1495
Open
milanmajchrak wants to merge 2 commits into
Open
milanmajchrak wants to merge 2 commits into
milanmajchrak wants to merge 2 commits into
Conversation
…ymous CLARIN searches Allowance and user-metadata records created by an anonymous download have no user registration. The authorize helpers let any signed-in user read them by ID, including the form data, IP address and download token. Now only an admin may read them. The CLARIN search methods (byEPerson, byBitstreamAndUser and, where it exists, byUserRegistrationAndBitstream) had no PreAuthorize, so an anonymous request ended with a NullPointerException and a 500. They now require an authenticated user and map AuthorizeException to 401 or 403. The link repositories map it the same way instead of returning a 500. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Without a matching record the services check nothing, so only the endpoint authorization can refuse these searches. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch has not been deployed
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.
References
Ports this dtq-dev PR:
DSpace PR 1588 ports the same dtq-dev PR. Only one of the two should be merged.
Description
A CLARIN allowance or user-metadata record without a user registration is now readable only by an admin. The CLARIN searches
byEPerson,byUserRegistrationAndBitstreamandbyBitstreamAndUserneed a signed-in user, so an anonymous call gets 401 instead of 500.Instructions for Reviewers
List of changes in this PR:
authorize…Actionhelpers inClarinLicenseResourceUserAllowanceServiceImpl,ClarinUserMetadataServiceImplandClarinUserRegistrationServiceImpl: only the owner or an admin passes. A record without a user registration (from an anonymous download) passes only for an admin. An anonymous caller is denied instead of hitting a NullPointerException.@PreAuthorize("hasAuthority('AUTHENTICATED')"), andAuthorizeExceptionbecomesRESTAuthorizationException. Anonymous gets 401, another user 403.ClarinLicenseResourceUserAllowanceRestRepositoryIT, plusfindOneWithoutUserRegistrationTest,findByUserRegistrationAndBitstreamTest,findByEPersonTestandlinksTestin the existing ITs. Each search test also sends an anonymous search that matches nothing and expects 401.How to test:
GET /api/core/clarinlruallowances/{id}of that record answers 403 for a normal user and 200 for an admin.GET /api/core/clarinuserregistrations/search/byEPerson?userUUID={uuid}without a token answers 401.byEPersonfor anonymous users.Codex review (gpt-6.2-sol, high), 2 rounds: 1 finding fixed (the search tests did not cover an anonymous search without a match), the last round found nothing.
Checklist
mainbranch of code (unless it is a backport or is fixing an issue specific to an older branch).pom.xml), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.🤖 Generated with Claude Code