Align dat.uuid.max_number_per_user default with documented value#12150
Open
officialasishkumar wants to merge 1 commit into
Open
Align dat.uuid.max_number_per_user default with documented value#12150officialasishkumar wants to merge 1 commit into
officialasishkumar wants to merge 1 commit into
Conversation
The documented default for dat.uuid.max_number_per_user is 1 (see docs/deployment/authorization-and-authentication/Authenticating-Users-via-Tokens.md and docs/deployment/customization/security.properties-Reference.md), but UuidDataAccessTokenServiceImpl declared the default as -1. With a default of -1 the limit check getNumberOfTokensForUsername(username) >= maxNumberOfAccessTokens always evaluates to true for any non-negative count, including zero, which causes the first token request for a user to attempt revoking the oldest token of an empty list and throw IndexOutOfBoundsException. Setting the default to 1 makes the behaviour match the docs (one outstanding token per user, replaced on each new request) and removes the latent crash. Add a regression test that verifies the default value resolves to 1 when the property is not configured, complementing the existing tests that exercise explicit values of 1 and 5. Closes cBioPortal#11907
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aligns the UUID data access token per-user default with the documented configuration value, fixing the mismatch described in #11907.
Changes:
- Updates
dat.uuid.max_number_per_userdefault from-1to1. - Adds a regression test verifying the default resolves to
1when unset.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/main/java/org/cbioportal/legacy/service/impl/UuidDataAccessTokenServiceImpl.java |
Changes the Spring @Value fallback for UUID token limit to 1. |
src/test/java/org/cbioportal/legacy/service/impl/UuidDataAccessTokenServiceImplDefaultsTest.java |
Adds coverage for the documented default value when the property is not configured. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
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.



Fix #11907
Describe changes proposed in this pull request:
@Valuedefault fordat.uuid.max_number_per_userinUuidDataAccessTokenServiceImplfrom-1to1, matching the value documented inAuthenticating-Users-via-Tokens.mdandsecurity.properties-Reference.md.UuidDataAccessTokenServiceImplDefaultsTest) that verifies the resolved value is1when the property is left unset.The previous default of
-1produced an unusable configuration.UuidDataAccessTokenServiceImpl.createDataAccessTokenperformsgetNumberOfTokensForUsername(username) >= maxNumberOfAccessTokensand then callsrevokeOldestDataAccessTokenForUsernamewhenever the check passes. WithmaxNumberOfAccessTokens = -1the inequality is satisfied for any non-negative count, including zero, so the very first token request for a user triggers a revoke against an empty token list and raisesIndexOutOfBoundsExceptionfromallDataAccessTokens.get(0). Operators who deployed UUID tokens without explicitly setting the property were therefore broken in a way that did not match the docs (which state a default of1with permissible values "greater than zero"). Switching the default to1gives the "one outstanding token, replaced on new requests" behaviour the docs already promise.Checks
Any screenshots or GIFs?
Not applicable — backend default value change.
Notify reviewers
Please use
git blameand the normal review flow forUuidDataAccessTokenServiceImpl.java(most recent touches to the token service / token configuration). Related issue #11921 covers the analogous mismatch fordat.ttl_secondsand is already assigned, so it is intentionally left out of this PR.