Skip to content

Add enable/disable switch for resource indicators to clients - #51230

Open
tnorimat wants to merge 3 commits into
keycloak:mainfrom
Hitachi:ISSUE-47121
Open

Add enable/disable switch for resource indicators to clients#51230
tnorimat wants to merge 3 commits into
keycloak:mainfrom
Hitachi:ISSUE-47121

Conversation

@tnorimat

Copy link
Copy Markdown
Contributor

closes #47121

closes keycloak#47121

Signed-off-by: Takashi Norimatsu <takashi.norimatsu.ws@hitachi.com>
Copilot AI review requested due to automatic review settings July 28, 2026 09:30
@tnorimat
tnorimat requested a review from a team as a code owner July 28, 2026 09:30

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

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) via OIDCAdvancedConfigWrapper and OIDCConfigAttributes.
  • Enforces the attribute in ResourceIndicatorsPostProcessor (token issuance) and AuthorizationEndpointChecker (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>
Copilot AI review requested due to automatic review settings July 30, 2026 20:37
@tnorimat
tnorimat requested a review from a team as a code owner July 30, 2026 20:37

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

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

edewit
edewit previously approved these changes Jul 31, 2026
closes keycloak#47121

Signed-off-by: Takashi Norimatsu <takashi.norimatsu.ws@hitachi.com>
Copilot AI review requested due to automatic review settings July 31, 2026 11:00

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

Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add enable/disable switch for resource indicators to clients

3 participants