Kimi K3.1 Pro · Heavy

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

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

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. Judge: Claude Haiku 5.5.

Gold bugs found
1 of 2
Comments published
6
Comments matching a bug
1
Comments not matching
5
Cost of this PR
$2.111

Published comments (6)

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

Disabled organizations suppress required IDP login-cache invalidation — For a disabled organization, `registerIDPLoginInvalidationOnUpdate` tests organization-effective `original` state, so hiding an IDP or making it link-only or private can skip invalidation; re-enabling the organization then serves the stale IDP. Evaluate the raw stored IDP from `idpDelegate.getById`, not organization-effective `isEnabled`.

mediumbugmodel/infinispan/src/main/java/org/keycloak/models/cache/infinispan/idp/InfinispanIdentityProviderStorageProvider.java:223

Login cache key conflates null and empty organization IDs — Because `searchKey` maps null and empty organization IDs to the same value, the first cached `ORG_ONLY` or `ALL` query can serve the other input, returning organization providers for a blank ID or dropping them for null. Encode null distinctly from an empty string.

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

Cold login-cache fill refetches every IDP through `getById` — With a cold IDP cache, each new mode/organization query adds N single-ID database lookups to the initial delegate query. Retain the models returned by `idpDelegate.getForLogin`, or bulk-load them, instead of refetching every ID through `getById`.

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

Login IDP cache test never exercises cache hits — The `query != null` branch in `getForLogin` can return wrong providers or throw while this test still passes, because every query is cold or follows invalidation and intermediate checks only inspect `IdentityProviderListQuery`. Repeat an identical mode/organization query without invalidation and assert its returned providers.

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

Login cache test does not exercise private organization-linked providers — Because every organization-linked provider sets `BROKER_PUBLIC=true`, removing the new organization/public clause in `getLoginPredicate()` leaves all expected counts unchanged. Add an enabled, organization-linked private provider and assert its exclusion from login results and the cache.

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

Cleanup registers a nonexistent alias and leaks the created providers — Cleanup targets the literal alias `alias`, so none of the generated providers is removed; the later registration repeats the mismatch for `idp-alias-20`, leaking providers into subsequent tests or failing cleanup. Register cleanup with each provider's actual alias.

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.