Skip to content

Cache federated-identity/service-account queries for already-managed users - #55240

Open
sguilhen wants to merge 1 commit into
keycloak:mainfrom
sguilhen:55237-usercache-federated-serviceaccount
Open

sguilhen wants to merge 1 commit into
keycloak:mainfrom
sguilhen:55237-usercache-federated-serviceaccount

Conversation

@sguilhen

@sguilhen sguilhen commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Closes #55237

@sguilhen
sguilhen requested review from a team as code owners November 16, 2026 17:35
Copilot AI balanced review requested due to automatic review settings November 16, 2026 17:35
@sguilhen
sguilhen force-pushed the 55237-usercache-federated-serviceaccount branch from 16c387a to 21d8613 Compare November 16, 2026 17:38

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

The test can pass with the old early return because the client representation request prepopulates the username query, preventing it from exercising the intended managed-user cache-miss path.

1 open issue
What changed in this PR

Extends the username/email caching fix from #54646 to federated-identity and service-account lookups, addressing #55237 when users are already managed in the session.

Changes:

  • Caches both lookup queries on eligible managed-user paths, preserving revision and lifespan handling.
  • Adds realm checks and a service-account client-link check.
  • Adds integration tests that inspect cache entries after sequential user lookups.
File Description
tests/​base/​src/​test/​java/​org/​keycloak/​tests/​model/​UserCacheManagedUserQueryTest.java Adds managed-user query-caching tests for both lookup types.
model/​infinispan/​src/​main/​java/​org/​keycloak/​models/​cache/​infinispan/​UserCacheSession.java Stores eligible lookup queries before returning already-managed users.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 16, 2026 17:38

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.

🔵 Needs a closer look

The regression test setup prepopulates the username query cache, so the lookup takes the cache-hit path and passes without the production fix rather than exercising the intended managed-user cache-miss branch.

1 open issue

Review effort: Balanced

…users

Closes keycloak#55237

Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
@sguilhen
sguilhen force-pushed the 55237-usercache-federated-serviceaccount branch from 21d8613 to d1973ad Compare November 16, 2026 17:45
Copilot AI balanced review requested due to automatic review settings November 16, 2026 17:45

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.

🟢 Approval recommended

No active review issues remain for the federated-identity and service-account query-caching changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@keycloak-github-bot keycloak-github-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unreported flaky test detected, please review

@keycloak-github-bot

Copy link
Copy Markdown

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.broker.KcSamlBrokerTest#loginClientWithDotsInName

Keycloak CI - FIPS IT (strict)

jakarta.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error
	at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.handleErrorStatus(ClientInvocation.java:250)
	at org.jboss.resteasy.client.jaxrs.internal.proxy.extractors.DefaultEntityExtractorFactory$3.extractEntity(DefaultEntityExtractorFactory.java:41)
	at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invokeSync(ClientInvoker.java:146)
	at org.jboss.resteasy.client.jaxrs.internal.proxy.ClientInvoker.invoke(ClientInvoker.java:104)
...

Report flaky test

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.

UserCacheSession.getUserByFederatedIdentity() and getServiceAccount() have the same managed-user early return as #54645

2 participants