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

closes keycloak#47128

Signed-off-by: Takashi Norimatsu <takashi.norimatsu.ws@hitachi.com>
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

Comment on lines +176 to +178
The authorization endpoint, the pushed authorization request endpoint, and the token endpoint accept the `resource` parameter multiple times.
{project_name} rejects a request sending it multiple times where it does not apply the `resource` parameter to the issued access token: an authorization request whose response type includes `token`, a device authorization request, and a token request of the pre-authorized code grant.
Such a request is also rejected when all the values are the same, or when the values are sent in a request object.
ClientModel newClientModel = newRealm == null ? null : newRealm.getClientById(clientId);
if (newClientModel != null) {
removeResourceIndicatorAudienceMapper(newClientModel, resource);
notAllowedResources.forEach(resource -> removeResourceIndicatorAudienceMapper(newClientModel, resource));
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