Kimi K3.1 Pro · Balanced

add-caching-support-for-identityproviderstorageprovider-getforlogin-operations-keycloak

Keycloak · Java · M · 100–299 lines · 3 files

The normal review, with one generalist agent. Judge: Claude Haiku 5.5.

Gold bugs found
1 of 2
Comments published
4
Comments matching a bug
1
Comments not matching
3
Cost of this PR
$1.272

Published comments (4)

mediumbugmodel/infinispan/src/main/java/org/keycloak/models/cache/infinispan/idp/InfinispanIdentityProviderStorageProvider.java:403-411

Organization-disabled brokers can skip login-cache invalidation — A disabled organization makes `original.isEnabled()` false even when the persisted broker is enabled, so `getLoginPredicate()` can skip invalidation and serve stale login results after re-enablement. Evaluate the predicate against the raw persisted broker from `idpDelegate.getById()`, or invalidate whenever a login-relevant field changes.

mediumbugserver-spi/src/main/java/org/keycloak/models/IdentityProviderStorageProvider.java:252-255

Case-insensitive broker-public check skips login cache invalidation — A case-only `BROKER_PUBLIC` change leaves both `getLoginPredicate()` results true, skipping invalidation even though the JPA delegate's query accepts only lowercase `true`, so login-cache membership becomes stale. Align the predicate with that exact comparison, or compare raw config values before deciding whether to invalidate.

mediumbugtestsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/organization/cache/OrganizationCacheTest.java:380-381

Cleanup targets a nonexistent alias and leaks test identity providers — Cleanup registered for the literal `alias` leaves every `idp-alias-*` broker behind, allowing these providers to contaminate later tests. Register cleanup for each actual alias, preferably with `getCleanup().addIdentityProviderAlias(...)`.

mediumperformancemodel/infinispan/src/main/java/org/keycloak/models/cache/infinispan/idp/InfinispanIdentityProviderStorageProvider.java:226-246

Login cache fills refetch every IDP and cause 1+N queries — A cold fill discards the models returned by `idpDelegate.getForLogin()` and then calls `getById()` for each cached ID, turning one login query into 1+N queries when per-IDP entries are cold. Cache their IDs, but return the loaded models through `createOrganizationAwareIdentityProviderModel()` instead of refetching them.

Gold bugs found (1)

lowThe test registers cleanup for the literal alias "alias" instead of the created IDP aliases, so the created identity providers are never cleaned up.

Gold bugs missed (1)

highAdding the organization/BROKER_PUBLIC check to the shared LoginFilter.getLoginPredicate also changes IdentityProviderBean.federatedProviderPredicate, so with organizations disabled a user's linked IdP that has an organizationId but is not public is no longer shown on the login page.