Repository navigation
Allow replacing existing federated identity link for same user (opt-in) - #48176
Oluwatobi-Mustapha wants to merge 1 commit into
Conversation
|
Hi @sguilhen, I’ve pushed a fix for #35059: #48176 It follows the direction we discussed:
Could you please review and let me know if you want any adjustments? |
547252c to
4c698ba
Compare
There was a problem hiding this comment.
Pull request overview
Adds an opt-in identity provider configuration that allows client-initiated account linking to replace an existing federated identity link for the same user (instead of failing), and emits a dedicated audit event when that override occurs.
Changes:
- Introduces
allowLinkingWithExistingFederatedIdentity(config key + accessor methods) onIdentityProviderModel. - Updates account-linking flow to detect an existing link for the current user and either fail (default) or replace the link (opt-in), emitting
FEDERATED_IDENTITY_OVERRIDE_LINK. - Extends broker tests to cover both “replacement disabled” and “replacement enabled” scenarios.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| services/src/main/java/org/keycloak/services/resources/IdentityBrokerService.java | Adds opt-in replacement logic for existing federated identity links and emits an override-link event. |
| server-spi/src/main/java/org/keycloak/models/IdentityProviderModel.java | Adds config key + getter/setter for the new opt-in behavior. |
| testsuite/integration-arquillian/tests/base/src/test/java/org/keycloak/testsuite/broker/KcOidcBrokerIdpLinkActionTest.java | Adds integration tests validating default failure vs opt-in replacement behavior and event emission. |
4129a4f to
f03f25b
Compare
f03f25b to
401da9d
Compare
|
@Oluwatobi-Mustapha Both new tests (
The |
|
@sguilhen Like you hinted, I added a docs section for the new option, covering the default behavior, the opt-in replacement behavior, and the fact that replacement only applies to the same authenticated user. I also kept the implementation note explaining why the replacement path uses remove+add instead of |
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.broker.KcOidcBrokerTest#loginWithExistingUserWithBruteForceEnabledKeycloak CI - Java Distribution IT (windows-latest - temurin - 21) |
df4f4d6 to
bad6606
Compare
bad6606 to
c263334
Compare
c263334 to
960c9c6
Compare
960c9c6 to
761f955
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Replacing an account link can retain the previous account’s refresh token in active sessions, allowing token exchange as the wrong account and potentially persisting its token against the new link.
1 open issue
2 resolved since last review
Review effort: Balanced
761f955 to
37a12ed
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Link replacement can persist and report a deprecated provider ID when both ownership lookups miss, and current test results for all supported database jobs are missing.
3 open issues
1 resolved since last review
Review effort: Balanced
Add opt-in replacement for client-initiated account linking and document the setting. Closes keycloak#35059 Signed-off-by: Oluwatobi Mustapha <oluwatobimustapha539@gmail.com>
37a12ed to
2b45edb
Compare
|
@sguilhen, please review when you can. |



Closes #35059
Let users switch their linked external account without unlinking first when the identity provider opts in.