Skip to content

Fallback to client_id when cid is missing#3790

Merged
duanemay merged 1 commit intodevelopfrom
fallback_cid_to_clientId
Mar 24, 2026
Merged

Fallback to client_id when cid is missing#3790
duanemay merged 1 commit intodevelopfrom
fallback_cid_to_clientId

Conversation

@duanemay
Copy link
Copy Markdown
Member

Handle missing or conflicting cid and client_id claims in token validation

Copilot AI review requested due to automatic review settings March 17, 2026 21:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates token validation and refresh-token processing to handle cases where the JWT cid claim is missing (and to better detect conflicting cid vs client_id), improving compatibility with legacy/external tokens.

Changes:

  • Update access-token client validation to accept client_id when cid is absent and to reject conflicting claims.
  • Update refresh-token flow to resolve the client ID via cid with fallback to client_id.
  • Add unit tests covering the new claim-resolution behaviors for both access-token validation and refresh-token exchange.

Reviewed changes

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

File Description
uaa/src/test/java/org/cloudfoundry/identity/uaa/oauth/UaaTokenServicesTests.java Adds a refresh-grant test to ensure refresh tokens missing cid but containing client_id can be exchanged.
server/src/test/java/org/cloudfoundry/identity/uaa/util/JwtTokenSignedByThisUAATest.java Adds tests for fallback to client_id, missing both claims, and conflicting claims.
server/src/main/java/org/cloudfoundry/identity/uaa/util/JwtTokenSignedByThisUAA.java Updates checkClient and getClientDetails to consider client_id when cid is missing.
server/src/main/java/org/cloudfoundry/identity/uaa/oauth/UaaTokenServices.java Uses cid with fallback to client_id when validating refresh token ownership and when loading client details / persisting revocable tokens.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Claims claims = getClaims(refreshTokenClaims);

// Token client id: prefer cid, fall back to client_id for legacy or external tokens
String tokenClientId = claims.getCid() != null ? claims.getCid() : claims.getClientId();
Comment on lines +281 to +282
String cid = (String) claims.get(CID);
String clientIdClaim = (String) claims.get(CLIENT_ID);
Comment on lines 464 to +467
String clientId = (String) claims.get(CID);
if (clientId == null) {
clientId = (String) claims.get(CLIENT_ID);
}
@github-project-automation github-project-automation bot moved this from Inbox to Pending Merge | Prioritized in Foundational Infrastructure Working Group Mar 19, 2026
@duanemay duanemay merged commit 1a70d55 into develop Mar 24, 2026
37 of 45 checks passed
@github-project-automation github-project-automation bot moved this from Pending Merge | Prioritized to Done in Foundational Infrastructure Working Group Mar 24, 2026
@duanemay duanemay deleted the fallback_cid_to_clientId branch March 24, 2026 20:07
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.

3 participants