Add enable/disable switch for resource indicators to clients - #51230
Open
tnorimat wants to merge 3 commits into
Open
Add enable/disable switch for resource indicators to clients#51230tnorimat wants to merge 3 commits into
tnorimat wants to merge 3 commits into
Conversation
closes keycloak#47121 Signed-off-by: Takashi Norimatsu <takashi.norimatsu.ws@hitachi.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds a per-client enable/disable switch for Resource Indicators and enforces it at token and authorization endpoints, with accompanying integration tests.
Changes:
- Introduces a new client attribute (
resource.indicators.enabled) viaOIDCAdvancedConfigWrapperandOIDCConfigAttributes. - Enforces the attribute in
ResourceIndicatorsPostProcessor(token issuance) andAuthorizationEndpointChecker(auth endpoint validation). - Adds integration tests covering the default-disabled behavior and server-side enforcement.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/base/src/test/java/org/keycloak/tests/oauth/ResourceIndicatorsTest.java | Adds tests for per-client enablement and updates test client config to opt-in. |
| services/src/main/java/org/keycloak/protocol/oidc/resourceindicators/ResourceIndicatorsPostProcessor.java | Rejects resource usage when the requesting client has Resource Indicators disabled. |
| services/src/main/java/org/keycloak/protocol/oidc/resourceindicators/ResourceIndicatorConstants.java | Adds an error string for “resource indicators disabled”. |
| services/src/main/java/org/keycloak/protocol/oidc/endpoints/AuthorizationEndpointChecker.java | Skips resource validation when feature disabled; rejects resource when client hasn’t enabled it. |
| services/src/main/java/org/keycloak/protocol/oidc/OIDCAdvancedConfigWrapper.java | Adds getters/setters for the new client attribute with a default value. |
| server-spi-private/src/main/java/org/keycloak/protocol/oidc/OIDCConfigAttributes.java | Declares the new resource.indicators.enabled attribute key. |
Comment on lines
+256
to
+259
| public boolean isResourceIndicatorsEnabled() { | ||
| String val = getAttribute(OIDCConfigAttributes.RESOURCE_INDICATORS_ENABLED, "false"); | ||
| return Boolean.parseBoolean(val); | ||
| } |
Comment on lines
+56
to
+59
| ClientModel requestingClient = context.clientSessionCtx().getClientSession().getClient(); | ||
| if (!OIDCAdvancedConfigWrapper.fromClientModel(requestingClient).isResourceIndicatorsEnabled()) { | ||
| throw new TokenInterceptorException(OAuthErrorException.INVALID_TARGET, ResourceIndicatorConstants.ERROR_RESOURCE_INDICATORS_DISABLED); | ||
| } |
Comment on lines
+159
to
+173
| ClientResource clientResource = realm.admin().clients() | ||
| .get(realm.admin().clients().findByClientId("test-app").get(0).getId()); | ||
| ClientRepresentation clientRep = clientResource.toRepresentation(); | ||
| clientRep.getAttributes().put(OIDCConfigAttributes.RESOURCE_INDICATORS_ENABLED, "false"); | ||
| clientResource.update(clientRep); | ||
|
|
||
| try { | ||
| AuthorizationEndpointResponse authorizationEndpointResponse = oauth.loginForm().resource("urn:client:theservice").doLoginWithCookie(); | ||
| Assertions.assertTrue(authorizationEndpointResponse.isRedirected()); | ||
| Assertions.assertEquals(INVALID_TARGET, authorizationEndpointResponse.getError()); | ||
| Assertions.assertEquals(ERROR_RESOURCE_INDICATORS_DISABLED, authorizationEndpointResponse.getErrorDescription()); | ||
| } finally { | ||
| clientRep.getAttributes().put(OIDCConfigAttributes.RESOURCE_INDICATORS_ENABLED, "true"); | ||
| clientResource.update(clientRep); | ||
| } |
closes keycloak#47121 Signed-off-by: Takashi Norimatsu <takashi.norimatsu.ws@hitachi.com>
edewit
previously approved these changes
Jul 31, 2026
closes keycloak#47121 Signed-off-by: Takashi Norimatsu <takashi.norimatsu.ws@hitachi.com>
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.
closes #47121