Skip to content

CLARIN-DSpace v9/Hide the magic handle token and make /api/core/handles admin-only - #1511

Open
milanmajchrak wants to merge 2 commits into
dtq-dev-93from
9-base/be-hide-magic-handle-token
Open

milanmajchrak wants to merge 2 commits into
dtq-dev-93from
9-base/be-hide-magic-handle-token

Conversation

@milanmajchrak

@milanmajchrak milanmajchrak commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

References

Port of #1508 (commit 1a22aac). dspace-customers issue 1071.

Description

Reads of /api/core/handles are admin-only now, and the token part of the magic URL is empty in every response.

Instructions for Reviewers

  • HandleRestRepository.findOne and findAll require ADMIN, like create, patch and delete. The only reader is the admin handle table.
  • Handle.hideToken() empties the token in every /api/core/handles response, the DB value stays. Handle.restoreToken() puts it back when an admin saves the URL as the API showed it.
  • POST /api/services/handles still returns the token it generated, PUT still needs it.
  • Handle reads a token only from a complete magic URL that starts with the marker, the same check hideToken uses. findByHandleAndMagicToken finds nothing for a blank token.
  • Apart from the point above and javax.ws.rs to jakarta.ws.rs in the IT, the diff is the same as dtq-dev PR 1508.
  • A blank token slot in a PATCH keeps the stored token, as on dtq-dev. To withdraw a token, an admin saves a new one; the IT checks that the old one then gets 404.
  • ITs HandleRestRepositoryIT and ExternalHandleRestRepositoryIT cover it. Compile and Checkstyle pass locally, the ITs run in CI.

Codex review (gpt-6.2-sol, high), 2 rounds: 3 findings fixed (token read only from a complete magic URL, marker required at the start, blank token rejected). Not changed: a PATCH cannot clear the token with a blank slot; same as dtq-dev, an admin replaces the token instead.

Checklist

  • My PR is created against the main branch of code (unless it is a backport or is fixing an issue specific to an older branch).
  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & integration tests). Exceptions may be made if previously agreed upon.
  • My PR passes Checkstyle validation based on the Code Style Guide.
  • My PR includes Javadoc for all new (or modified) public methods and classes. It also includes Javadoc for large or complex private methods.
  • My PR passes all tests and includes new/updated Unit or Integration Tests based on the Code Testing Guide.
  • My PR includes details on how to test it. I've provided clear instructions to reviewers on how to successfully test this fix or feature.
  • If my PR includes new libraries/dependencies (in any pom.xml), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.
  • If my PR modifies REST API endpoints, I've opened a separate REST Contract PR related to this change.
  • If my PR includes new configurations, I've provided basic technical documentation in the PR itself.
  • If my PR fixes an issue ticket, I've linked them together.

🤖 Generated with Claude Code

…es admin-only

Port of dtq-dev PR 1508 (commit 1a22aac) to the v9 base. Only the javax import in the IT changed to jakarta.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@milanmajchrak
milanmajchrak changed the base branch from dtq-dev-9-base to dtq-dev-93 November 17, 2026 15:56
The constructor uses the same format check as hideToken, a magic URL must start
with the marker as in HandlePlugin, and a blank token never matches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant