Skip to content

Support multiple resource parameters - #55345

Open
tnorimat wants to merge 1 commit into
keycloak:mainfrom
Hitachi:ISSUE-47128
Open

tnorimat wants to merge 1 commit into
keycloak:mainfrom
Hitachi:ISSUE-47128

Conversation

@tnorimat

Copy link
Copy Markdown
Contributor

closes #47128

@tnorimat
tnorimat requested a review from a team as a code owner November 19, 2026 08:19
Copilot AI balanced review requested due to automatic review settings November 19, 2026 08:19

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.

🟡 Changes recommended

Several resource-handling paths can bypass audience restrictions and allow-list checks, potentially issuing unrestricted tokens.

11 open issues
What changed in this PR

Extends Keycloak’s experimental Resource Indicators support to accept multiple resource parameters, addressing #47128.

Changes:

  • Parses multiple resource values and supports requesting subsets of previously granted resources.
  • Extends Client ID Metadata Document allow-list checks and audience-mapper management.
  • Adds integration coverage, test helpers, and documentation.
File Description
tests/​utils-shared/​src/​main/​java/​org/​keycloak/​testsuite/​util/​oauth/​ParRequest.java Adds a resource parameter helper for pushed requests.
tests/​utils-shared/​src/​main/​java/​org/​keycloak/​testsuite/​util/​oauth/​LoginUrlBuilder.java Builds login URLs with repeated resource parameters.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​oauth/​ResourceIndicatorsTest.java Covers multiple resources, subsets, refreshes, and pushed requests.
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​client/​policies/​ClientIdMetadataDocumentTest.java Tests multi-resource allow lists and audience-mapper updates.
services/​src/​main/​java/​org/​keycloak/​protocol/​oidc/​resourceindicators/​ResourceIndicatorsPostProcessor.java Resolves resource sets and restricts token audiences.
services/​src/​main/​java/​org/​keycloak/​protocol/​oidc/​resourceindicators/​ResourceIndicators.java Adds shared resource-set serialization and parsing.
services/​src/​main/​java/​org/​keycloak/​protocol/​oidc/​par/​endpoints/​ParEndpoint.java Validates and preserves multiple pushed resource values.
services/​src/​main/​java/​org/​keycloak/​protocol/​oidc/​grants/​ResourceOwnerPasswordCredentialsGrantType.java Passes all requested resources into password-grant processing.
services/​src/​main/​java/​org/​keycloak/​protocol/​oidc/​grants/​RefreshTokenGrantType.java Collects multiple resources from refresh requests.
services/​src/​main/​java/​org/​keycloak/​protocol/​oidc/​grants/​OAuth2GrantTypeBase.java Allows repeated resources and propagates them during token issuance.
services/​src/​main/​java/​org/​keycloak/​protocol/​oidc/​endpoints/​request/​AuthzEndpointRequestParser.java Applies parameter-length checks to individual resource values.
services/​src/​main/​java/​org/​keycloak/​protocol/​oidc/​endpoints/​request/​AuthzEndpointRequestObjectParser.java Parses resource arrays from request objects.
services/​src/​main/​java/​org/​keycloak/​protocol/​oidc/​endpoints/​request/​AuthzEndpointQueryStringParser.java Accepts repeated resources when the feature is enabled.
services/​src/​main/​java/​org/​keycloak/​protocol/​oidc/​endpoints/​AuthorizationEndpointChecker.java Validates every resource indicator.
services/​src/​main/​java/​org/​keycloak/​protocol/​oauth2/​cimd/​clientpolicy/​executor/​AbstractClientIdMetadataDocumentExecutor.java Checks resource sets and synchronizes managed audience mappers.
docs/​guides/​securing-apps/​mcp-authz-server.adoc Documents multiple resources, subsets, and allow-list behavior.
docs/​documentation/​release_notes/​topics/​27_0_0.adoc Announces experimental multi-resource support.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 20, 2026 10:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Copilot AI balanced review requested due to automatic review settings November 20, 2026 12:03

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.

🟡 Changes recommended

OID4VCI processing can replace requested audiences with an unrequested credential endpoint, while mapper cleanup and JWT grant error handling also have unresolved issues.

3 open issues
3 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 20, 2026 14:52

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.

🟡 Changes recommended

Rejected requests can delete another policy’s resource mapper and break refresh tokens, while the documentation omits that token exchange does not enforce resource indicators.

2 open issues
3 resolved since last review

Review effort: Balanced

closes keycloak#47128

Signed-off-by: Takashi Norimatsu <takashi.norimatsu.ws@hitachi.com>
Copilot AI balanced review requested due to automatic review settings November 21, 2026 12:32

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.

🟡 Changes recommended

Critical resource-enforcement gaps can bypass the CIMD allow list, ignore restrictions in custom grants, or alter credential-endpoint audiences; UMA requests can also fail incorrectly.

4 open issues
1 resolved since last review

Review effort: Balanced

case AUTHORIZATION_REQUEST_REDIRECT_URI:
// the resource parameter needs to be enforced on every authorization request. It is done after the
// request is parsed, so that the values sent by PAR or in a request object are enforced as well.
enforceResourceIndicator((AuthorizationRequestRedirectUriContext) context);
// the processors with a higher order run first. This one runs after the ones with the default order, so that
// the resources are resolved against the audience that the other processors may have restricted (e.g. OID4VCI)
// and none of them replaces the audience afterwards.
return -1;
protected TokenManager.AccessTokenResponseBuilder createTokenResponseBuilder(UserModel user, UserSessionModel userSession, ClientSessionContext clientSessionCtx, String scopeParam, Function<TokenManager.AccessTokenResponseBuilder, ClientPolicyContext> clientPolicyContextGenerator) {
clientSessionCtx.setAttribute(Constants.GRANT_TYPE, context.getGrantType());
clientSessionCtx.setAttribute(OAuth2Constants.RESOURCE, formParams.getFirst(OAuth2Constants.RESOURCE));
clientSessionCtx.setAttribute(OAuth2Constants.RESOURCE, getRequestedResources());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support multiple resource parameters

2 participants