Skip to content

[CIMD] Stale resource audience mapper persists after allowlist tightening - #55212

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

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

Conversation

@tnorimat

Copy link
Copy Markdown
Contributor

closes #55131

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

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

Revoked audiences can still appear in tokens from client-credentials and refresh-token grants, and authorization-time cleanup can roll back when later checks fail.

2 open issues
What changed in this PR

This PR addresses stale CIMD resource-audience mappers described in #55131 by reconciling them against the current allowlist during authorization requests.

Changes:

  • Removes stale mappers even when resource is omitted or a still-allowed resource is requested.
  • Removes CIMD-owned audience mappers when Resource Indicators are disabled.
  • Adds regression tests for omitted-resource and alternate-resource authorization requests.
File Description
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​client/​policies/​ClientIdMetadataDocumentTest.java Tests mapper cleanup after allowlist tightening.
services/​src/​main/​java/​org/​keycloak/​protocol/​oauth2/​cimd/​clientpolicy/​executor/​AbstractClientIdMetadataDocumentExecutor.java Reconciles CIMD audience mappers during authorization.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 16, 2026 04:21

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.

Copilot AI balanced review requested due to automatic review settings November 16, 2026 05:46

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.

Copilot AI balanced review requested due to automatic review settings November 16, 2026 06:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Copilot AI balanced review requested due to automatic review settings November 16, 2026 08:56

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.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 01:42

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.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 02:35

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.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 03:29

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.

…ning

closes keycloak#55131

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

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.

Comment on lines +1195 to +1196
if (realm != null && Objects.equals(realm.getAttribute(RECONCILED_REALM_ATTRIBUTE), state.reconciled())) {
realm.setAttribute(RECONCILED_REALM_ATTRIBUTE, state.fingerprint());
Comment on lines +1277 to +1278
for (ClientModel client : clients) {
removeStaleResourceIndicatorAudienceMappers(session, client, allowLists.getAllowList(client.getClientId()));
return Collections.emptyList();
}
List<List<String>> applicableAllowLists = enabledPolicies.stream()
.filter(p -> isApplicable(p, clientId))
Comment on lines +119 to +121
protected void commitImpl() {
AbstractClientIdMetadataDocumentExecutor.removeStaleResourceIndicatorAudienceMappers(factory, realmId,
executorProviderId, configurationClass);
Comment on lines +171 to +172
timer.schedule(new ClusterAwareScheduledTaskRunner(factory, new ReconciliationTask(executorProviderId), RECONCILIATION_INTERVAL_MILLIS),
RECONCILIATION_INITIAL_DELAY_MILLIS, RECONCILIATION_INTERVAL_MILLIS);
Comment on lines +169 to +173
try (KeycloakSession session = factory.create()) {
TimerProvider timer = session.getProvider(TimerProvider.class);
timer.schedule(new ClusterAwareScheduledTaskRunner(factory, new ReconciliationTask(executorProviderId), RECONCILIATION_INTERVAL_MILLIS),
RECONCILIATION_INITIAL_DELAY_MILLIS, RECONCILIATION_INTERVAL_MILLIS);
}
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.

[CIMD] Stale resource audience mapper persists after allowlist tightening

2 participants