Skip to content

CTM-553 - Make bearer token optional in postAccessURL endpoint#2113

Draft
snf2ye wants to merge 1 commit into
developfrom
sh/optional-bearer-token-post-access-url
Draft

CTM-553 - Make bearer token optional in postAccessURL endpoint#2113
snf2ye wants to merge 1 commit into
developfrom
sh/optional-bearer-token-post-access-url

Conversation

@snf2ye

@snf2ye snf2ye commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

https://broadworkbench.atlassian.net/browse/CTM-553

Summary

  • postAccessURL (POST /ga4gh/drs/v1/objects/{object_id}/access/{access_id}) previously called bearerTokenFactory.from(request) unconditionally, throwing UnauthorizedException if no Authorization header was present.
  • The bearer token is only actually used in DrsService.signGoogleUrl when two conditions are both true: the snapshot is self-hosted AND an x-user-project header is provided. In all other cases (non-self-hosted snapshots, or self-hosted with no user project) the token is never accessed.
  • This change defers token enforcement to the service layer, which already handles a null token gracefully.

Note on the non-self-hosted case

Even when x-user-project is provided, if the snapshot is not self-hosted the bearer token is still never used — the URL is signed using the snapshot's own Google project credentials. So even Option A (only requiring the token when x-user-project is present) would have been overly strict. By checking the Authorization header and passing null when absent, we let the natural enforcement point in signGoogleUrl fire only when it actually needs the token.

Test plan

  • Existing unit tests updated to expect null token when no Authorization header is sent
  • testPostAccessURLPassesNullTokenWhenNoAuthHeader — verifies requests without an Authorization header succeed (token passed as null to service)
  • testPostAccessURLPassesTokenWhenAuthHeaderPresent — verifies the token is still extracted and forwarded when the header is present
  • All DataRepositoryServiceApiControllerTest tests pass

🤖 Generated with Claude Code

The Authorization header is only required for self-hosted snapshots accessed
with an x-user-project header. Eagerly throwing when the header is absent
blocked passport-auth users who don't need the token at all. Defer enforcement
to the service layer, which already handles a null token correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@snf2ye snf2ye changed the title Make bearer token optional in postAccessURL endpoint CTM-553 - Make bearer token optional in postAccessURL endpoint Jun 17, 2026
@snf2ye
snf2ye marked this pull request as ready for review June 17, 2026 13:28
@snf2ye
snf2ye requested a review from a team as a code owner June 17, 2026 13:28
@snf2ye
snf2ye requested review from calypsomatic and davidangb and removed request for a team June 17, 2026 13:28
@snf2ye
snf2ye marked this pull request as draft June 17, 2026 13:30
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.

2 participants