Return a minimal response for inactive tokens in /introspect - #4066
Draft
duanemay wants to merge 1 commit into
Draft
Return a minimal response for inactive tokens in /introspect#4066duanemay wants to merge 1 commit into
duanemay wants to merge 1 commit into
Conversation
RFC 7662 section 2.2 requires an inactive-token response to contain only "active": false and nothing else. IntrospectEndpoint was reusing an empty IntrospectionClaims instance for this case, but IntrospectionClaims inherits a primitive `revocable` field from Claims that @JsonInclude(NON_NULL) cannot suppress, so the response leaked "revocable":false alongside "active":false. Return a plain minimal value for the inactive case instead, while leaving the active-token response unchanged (so a legitimately false `revocable` claim on an active token still appears, as it should).
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped, aligns with RFC 7662 requirements, and is covered by updated unit tests plus a new HTTP-level regression test.
Pull request overview
This PR updates UAA’s /introspect endpoint to comply with RFC 7662 §2.2 by returning a truly minimal response for inactive tokens ({"active": false}), avoiding leakage of additional fields (e.g., revocable:false) that can be unintentionally serialized due to primitive defaults.
Changes:
- Changed
IntrospectEndpoint#introspectto return a minimal inactive-token payload (Map.of("active", false)) for expired/invalid tokens, and fullIntrospectionClaimsonly for active tokens. - Updated and added tests to assert the inactive response contains only the
activefield, including a new HTTP-level MockMvc assertion. - Added a regression test ensuring an active token’s explicit
"revocable": falseclaim is still returned (not suppressed).
File summaries
| File | Description |
|---|---|
server/src/main/java/org/cloudfoundry/identity/uaa/oauth/IntrospectEndpoint.java |
Returns a minimal inactive-token response and preserves full claims for active tokens. |
server/src/test/java/org/cloudfoundry/identity/uaa/oauth/IntrospectEndpointTest.java |
Adjusts unit tests for the new inactive payload and adds a regression test for revocable:false on active tokens. |
uaa/src/test/java/org/cloudfoundry/identity/uaa/oauth/IntrospectEndpointMockMvcTest.java |
Adds an HTTP-level test asserting the inactive response body contains only active:false. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+26
to
+29
| // RFC 7662 section 2.2: an inactive-token response MUST contain only "active": false | ||
| // and SHOULD NOT include any other information about the token. IntrospectionClaims | ||
| // has other fields (e.g. `revocable`, a primitive) that can't be suppressed via | ||
| // @JsonInclude once populated, so the inactive case returns this minimal value instead. |
Comment on lines
+90
to
+92
| .andExpect(status().isOk()) | ||
| .andExpect(content().string("{\"active\":false}")); | ||
| } |
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.
Summary
"active": falseand nothing else — the authorization server SHOULD NOT include any additional information about an inactive token.IntrospectEndpointwas returning an emptyIntrospectionClaimsinstance for expired/invalid tokens, relying on@JsonInclude(NON_NULL)to hide unset fields. That doesn't work forrevocable, which is a primitivebooleaninherited fromClaims— primitives can't be null, so Jackson always serializes their default value. The response leaked"revocable":falsealongside"active":false.IntrospectEndpoint#introspectnow returns a plain minimal value ({"active": false}) for the inactive cases, and the populatedIntrospectionClaimsobject only for the active case. This was chosen over suppressingrevocablevia@JsonIncludebecause that would also hide a legitimately-falserevocablevalue on an active token's response, which is real information that should still be returned.Test plan
IntrospectEndpointTest#expiredTokenIsInactive/invalidToken_inReadAccessToken/invalidToken_inLoadAuthentication/invalidJSONInClaims— updated to assert the inactive response is exactly{"active": false}.IntrospectEndpointTest#falseRevocableClaimIsNotSuppressedOnActiveToken— new test confirming an active token with an explicit"revocable":falseclaim still returns it.IntrospectEndpointMockMvcTest#invalidTokenResponseContainsOnlyActiveField— new HTTP-level test asserting the raw response body for an invalid token is exactly{"active":false}.IntrospectEndpointTest,IntrospectEndpointMockMvcTest, andCheckTokenEndpointTestssuites pass unchanged.