Skip to content

expand refresh token validity resolver#3942

Merged
duanemay merged 2 commits into
cloudfoundry:developfrom
fhanik:pr/expand-refresh-token-validity-resolver
Jun 12, 2026
Merged

expand refresh token validity resolver#3942
duanemay merged 2 commits into
cloudfoundry:developfrom
fhanik:pr/expand-refresh-token-validity-resolver

Conversation

@fhanik

@fhanik fhanik commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Enhance the TokenValidityResolver bean to have access to more context information when determining validity time for a token.

Added example to showcase how it can be used.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enhances refresh token TTL determination by expanding the TokenValidityResolver extension point so it can receive request context (RefreshTokenRequestData) when resolving refresh token expiration, and adds a MockMvc-based example demonstrating how a proprietary module could clamp refresh token validity based on assertion/session context.

Changes:

  • Add TokenValidityResolver.resolve(clientId, RefreshTokenRequestData) overload (default delegates to existing resolve(clientId)).
  • Pass RefreshTokenRequestData into the refresh token validity resolver from RefreshTokenCreator.
  • Allow overriding the default refreshTokenValidityResolver bean via @ConditionalOnMissingBean, and add/update tests (unit + MockMvc example).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
uaa/src/test/java/org/cloudfoundry/identity/uaa/mock/token/JitRefreshTokenExpirationMockMvcTests.java Adds an integration-style example test showing custom refresh-token expiry clamping using request context.
server/src/test/java/org/cloudfoundry/identity/uaa/oauth/refresh/RefreshTokenCreatorTest.java Updates mocking to match the new resolver method signature used by RefreshTokenCreator.
server/src/main/java/org/cloudfoundry/identity/uaa/oauth/TokenValidityResolver.java Adds the new overload accepting RefreshTokenRequestData as an extension point.
server/src/main/java/org/cloudfoundry/identity/uaa/oauth/refresh/RefreshTokenCreator.java Switches refresh token expiration resolution to call the new overload with request context.
server/src/main/java/org/cloudfoundry/identity/uaa/oauth/beans/OauthEndpointBeanConfiguration.java Makes the default refreshTokenValidityResolver bean conditional so custom implementations can replace it cleanly.

Comment on lines +47 to +51
* <li>A {@link UaaTokenEnhancer} that deposits a {@code exampleRefreshTokenExpiration} claim
* (read in production from {@code UaaAuthentication#getIdpIdToken()}) into the
* token's external attributes map.</li>
* <li>A {@link TokenValidityResolver} subclass that reads that claim and clamps the
* refresh token's TTL to {@code min(requestedExpiration, defaultExpiration)}.</li>
Comment on lines +126 to +134
Object claim = requestData.externalAttributes.get("exampleRefreshTokenExpiration");
if (claim == null) {
return defaultExpiration;
}
Instant requested = Instant.parse(claim.toString());
return requested.isBefore(defaultExpiration.toInstant())
? Date.from(requested)
: defaultExpiration;
}
Comment on lines +169 to +171
long expectedDefault = Instant.now().plusSeconds(2592000).getEpochSecond();
long expClaim = getRefreshTokenExpClaim(refreshToken);
assertThat(expClaim).isCloseTo(expectedDefault, within(10L));
Comment on lines +184 to +186
long expectedDefault = Instant.now().plusSeconds(2592000).getEpochSecond();
long expClaim = getRefreshTokenExpClaim(refreshToken);
assertThat(expClaim).isCloseTo(expectedDefault, within(10L));
@duanemay duanemay merged commit f5565a2 into cloudfoundry:develop Jun 12, 2026
33 of 34 checks passed
@github-project-automation github-project-automation Bot moved this from Pending Merge | Prioritized to Done in Foundational Infrastructure Working Group Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

4 participants