-
Notifications
You must be signed in to change notification settings - Fork 0
Add caching support for IdentityProviderStorageProvider.getForLogin operations #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature-idp-cache-baseline
Are you sure you want to change the base?
Add caching support for IdentityProviderStorageProvider.getForLogin operations #73
Conversation
Closes #32573 Signed-off-by: Stefan Guilhen <[email protected]>
|
@claude review this PR |
1 similar comment
|
@claude review this PR |
|
Claude finished @akshayutture-augment's task —— View job Code Review for PR: Add caching support for IdentityProviderStorageProvider.getForLogin operationsI've completed a thorough review of this PR. Overall, the implementation is well-structured and follows the existing caching patterns in the codebase. Here are my findings: ✅ Strengths
🔍 Issues and Concerns1. Potential Cache Inconsistency (Medium Severity)Location: InfinispanIdentityProviderStorageProvider.java:244-252 Set<IdentityProviderModel> identityProviders = new HashSet<>();
for (String id : cached) {
IdentityProviderModel idp = session.identityProviders().getById(id);
if (idp == null) {
realmCache.registerInvalidation(cacheKey);
return idpDelegate.getForLogin(mode, organizationId).map(this::createOrganizationAwareIdentityProviderModel);
}
identityProviders.add(idp);
}Issue: When an IDP is deleted, the cached IDP ID list isn't immediately invalidated. The code detects this (line 247) and falls back to the delegate, but there's a timing window where stale data could be served. Recommendation: Consider proactively invalidating login caches in the 2. Missing Organization Invalidation in getForLogin CacheLocation: InfinispanIdentityProviderStorageProvider.java:214-255 Issue: When an organization is updated or deleted, the Scenario: If an organization is disabled or deleted, cached login IDPs associated with that organization may still be returned until the cache naturally expires. Recommendation: Add an organization invalidation check similar to line 173: if (isInvalid(cacheKey) || (organizationId != null && isInvalid(organizationId))) {
return idpDelegate.getForLogin(mode, organizationId).map(this::createOrganizationAwareIdentityProviderModel);
}3. Code Duplication (Low Severity)Location: InfinispanIdentityProviderStorageProvider.java:168-211 and 214-255 Issue: The Recommendation: Consider extracting a common method: private Stream<IdentityProviderModel> getCachedIDPStream(
String cacheKey,
String searchKey,
java.util.function.Supplier<Stream<IdentityProviderModel>> delegateSupplier,
String... additionalInvalidationKeys) {
// Common caching logic here
}4. Minor: Method Visibility InconsistencyLocation: InfinispanIdentityProviderStorageProvider.java:77 Issue: The Recommendation: Review if 🧪 Test Coverage AssessmentThe test coverage is excellent:
Missing test case: Test what happens when an IDP in the cache is deleted (the null check scenario on line 247). 📝 Minor Observations
🎯 Recommendations SummaryHigh Priority:
Medium Priority:
Low Priority:
✅ ConclusionThis is a solid implementation that improves performance for a critical operation. The caching strategy is sound, the tests are comprehensive, and the code follows existing patterns. The main concerns are around cache invalidation edge cases that could lead to stale data in specific scenarios. I recommend addressing the organization invalidation issue (#2) before merging. Approval Status: ✅ Approve with minor changes requested |
Test 2
Replicated from ai-code-review-evaluation/keycloak-greptile#2