Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Several resource-handling paths can bypass audience restrictions and allow-list checks, potentially issuing unrestricted tokens.
11 open issues
Match PAR URI prefixes case-insensitively in resource checks · New Apply resource policy to verified request-object values · New Persist and enforce resources for device authorization requests · New Reject oversized resource sets instead of dropping audience restrictions · New Restrict repeated resources to grants that validate them · New Reject oversized multivalued resources instead of silently dropping them · New Enforce requested resources when building implicit and hybrid tokens · New Preserve resource constraints when rebuilding offline refresh context · New Bound the total serialized size of resource parameters · New Validate narrowed refresh resources against effective scopes · New Allow refresh tokens containing multiple resource URIs · New
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
841a669 to
147263c
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Duplicate resources in implicit or hybrid requests and multi-resource device request objects can bypass validation, allowing tokens to be issued without the requested audience restrictions.
3 open issues
11 resolved since last review
Preserve resource constraints when rebuilding offline refresh context Enforce requested resources when building implicit and hybrid tokens Reject oversized multivalued resources instead of silently dropping them Restrict repeated resources to grants that validate them Reject oversized resource sets instead of dropping audience restrictions Persist and enforce resources for device authorization requests Apply resource policy to verified request-object values Match PAR URI prefixes case-insensitively in resource checks Allow refresh tokens containing multiple resource URIs Validate narrowed refresh resources against effective scopes Bound the total serialized size of resource parameters
Review effort: Balanced
147263c to
b57b143
Compare
There was a problem hiding this comment.
🟡 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>
b57b143 to
448bd5b
Compare
There was a problem hiding this comment.
🟡 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
| 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)); |


closes #47128