Repository navigation
Cleanup orphaned broker links when duplicate federated identities found - #45124
Rathan-Naik wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
@Rathan-Naik thank you for preparing the PR. LGTM.
@pedroigor since you're more familiar with the context, can you please also take a look?
7674b9f to
cc50c0f
Compare
When a federated user (e.g., from LDAP) is deleted from the external source, the broker link record in Keycloak is not cleaned up. If a new user with the same IdP mapping logs in later, a second broker link is created. On subsequent logins, the query returns multiple results and throws IllegalStateException. This fix: - In JpaUserFederatedStorageProvider: resolves multiple BrokerLinkEntity records by checking if each user still exists, removing orphaned links - In JpaUserProvider: resolves multiple FederatedIdentityEntity records by checking if federated users still exist, removing orphaned identities Closes keycloak#44933 Signed-off-by: Rathan Naik <30756840+Rathan-Naik@users.noreply.github.com>
4dd7c40 to
4c1244c
Compare
|
@Rathan-Naik - Please avoid merging the main branch into the PR or rebasing the PR unless there are merge conflicts reported by GitHub or a reviewer asks you for a rebase. This prevents spamming reviewers with notifications and saves minutes on the GitHub actions CI. Thanks! |
Noted. |
When a federated user (e.g., from LDAP) is deleted from the external source, the broker link record in Keycloak is not cleaned up. If a new user with the same IdP mapping logs in later, a second broker link is created. On subsequent logins, the query returns multiple results and throws IllegalStateException.
This fix:
In both JpaUserFederatedStorageProvider and JpaUserProvider, when multiple results are found:
This approach cleans up stale data automatically while preserving the error for genuine duplicate scenarios.
Closes #44933