Add caching support for IdentityProviderStorageProvider.getForLogin operations#9
Add caching support for IdentityProviderStorageProvider.getForLogin operations#9zaibkhan wants to merge 1 commit into
Conversation
Closes #32573 Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
Codoki PR ReviewSummary: Add login IDP caching, ensure invalidations, tighten filtering Issues (Medium)
Showing up to 2 medium issue(s). See inline suggestions for more details. Key Feedback (click to expand)
Confidence: 4/5 — Looks good; minor fixes (2 medium) Sequence DiagramsequenceDiagram
participant Caller
participant InfinispanIDP as InfinispanIdentityProviderStorageProvider
participant Delegate as idpDelegate
participant Cache as RealmCacheManager
Caller->>InfinispanIDP: getForLogin(mode, organizationId)
alt cache invalid
InfinispanIDP->>Delegate: getForLogin(mode, organizationId)
Delegate-->>InfinispanIDP: Stream<IdentityProviderModel>
InfinispanIDP-->>Caller: Stream (mapped)
else cache present
InfinispanIDP->>Cache: get(cacheKey)
alt query null
InfinispanIDP->>Delegate: getForLogin(mode, organizationId)
Delegate-->>InfinispanIDP: Stream ids
InfinispanIDP->>Cache: addRevisioned(query)
else searchKey missing
InfinispanIDP->>Cache: invalidateObject(cacheKey)
InfinispanIDP->>Delegate: getForLogin(mode, organizationId)
Delegate-->>InfinispanIDP: Stream ids
InfinispanIDP->>Cache: addRevisioned(query)
end
InfinispanIDP-->>Caller: Stream from cached ids
end
React with 👍 or 👎 if you found this review useful. |
| return identityProviders.stream(); | ||
| } | ||
|
|
||
| @Override |
There was a problem hiding this comment.
🔷 Medium: Consider also invalidating when the specific organization is invalidated. Otherwise, an ORG_ONLY/ALL query with a removed/updated org could serve stale results until a later IDP change triggers cache invalidation.
suggestion
if (isInvalid(cacheKey) || (organizationId != null && isInvalid(organizationId))) {
return idpDelegate.getForLogin(mode, organizationId).map(this::createOrganizationAwareIdentityProviderModel);
}
| idpRep.setDisplayName("Broker " + i); | ||
| idpRep.setProviderId("keycloak-oidc"); | ||
| if (i >= 10) | ||
| idpRep.getConfig().put(OrganizationModel.BROKER_PUBLIC, Boolean.TRUE.toString()); |
There was a problem hiding this comment.
🔷 Medium: The cleanup references a hardcoded alias string, so created IDPs are not removed. Capture the actual alias per iteration to avoid leaking test data and side effects.
suggestion
String createdAlias = idpRep.getAlias();
getCleanup().addCleanup(() -> testRealm().identityProviders().get(createdAlias).remove());
No description provided.