GLM-5.3 Flash · 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 Opus 5.5.

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

Published comments (3)

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

Login cache invalidation skipped when org-aware wrapper masks IDP login eligibility — When the organization is disabled, the org-aware wrapper's `isEnabled()` makes `getLoginPredicate()` false, so updates like removing `BROKER_PUBLIC` or hiding or disabling the IDP skip invalidation and stale `.idp.login` caches serve a hidden broker after re-enabling. Evaluate the predicate on the unwrapped model, e.g. via `idpDelegate.getByAlias()`.

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

Login cache uses empty-string sentinel that collides with empty organizationId — When a call passes an empty-string `organizationId`, the wrong result lands under the `""` key and later `null`-filter lookups skip the re-fetch, returning an empty list until invalidation. Use a non-colliding sentinel like `getByOrganization`'s `-1.-1`, or normalize empty strings to `null`.

mediumbugservices/src/main/java/org/keycloak/organization/forms/login/freemarker/model/OrganizationAwareIdentityProviderBean.java:72-83

isEnabled re-check in OrganizationAwareIdentityProviderBean lacks test coverage — If this `isEnabled()` filter broke, the suite would still pass, since `testCacheIDPForLogin` calls `getForLogin` directly and never renders through the bean. Add a test path that exercises `OrganizationAwareIdentityProviderBean`, or assert on the models it resolves.

Gold bugs found (1)

mediumLogin-cache invalidation on update compares the organization-aware enabled state, so changing a broker to private while its organization is disabled skips invalidation and leaves the now-private IDP in the cached login list.

Gold bugs missed (6)

lowThe test registers cleanup for the literal alias "alias" instead of the created IDP aliases, so the created identity providers are never cleaned up.
mediumOn a partial cache miss getForLogin merges the previously read login query into a newly revisioned entry, so a concurrent invalidation can be lost and stale IDP IDs for other organizations persist.
mediumregisterIDPLoginInvalidationOnUpdate returns early when the IDP stays a login IDP with the same organizationId without comparing BROKER_PUBLIC, so toggling kc.org.broker.public on a realm-level IDP leaves the login caches stale.
mediumThe cache-hit path of getForLogin collects IDPs into a HashSet and streams it, so results come in hash order instead of the delegate's order returned on a miss, making ordering differ by cache state.
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.
mediumgetLoginPredicate treats BROKER_PUBLIC case-insensitively, but the JPA delegate matches the exact value "true". An update that only changes the case (e.g. true -> TRUE) skips login-cache invalidation, so the cached login IDP list no longer matches the delegate.