Repository navigation
Conversation
…another browser Closes keycloak#55287 Signed-off-by: George McGinley Smith <george@mukuru.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are identified for the cross-browser registration restart changes.
No open issues 🎉
What changed in this PR
Fixes #55287 by letting the original registration browser restart at login after email verification in another browser, preserving the client’s authorization request and PKCE parameters without restoring automatic login.
Changes:
- Sets restart cookies for client-initiated registration and updates them to restart at login once email verification is required.
- Adds parameterized tests for cross-browser verification, PKCE code redemption, and expired registration sessions.
- Clarifies that the legacy password-on-registration switch does not restore cross-browser login continuation.
| File | Description |
|---|---|
| tests/base/src/test/java/org/keycloak/tests/forms/RegisterWithEmailVerificationTest.java | Tests registration restart behavior across entry points and password configurations. |
| services/src/main/java/org/keycloak/protocol/oidc/endpoints/AuthorizationEndpoint.java | Sets the restart cookie for client-initiated registration. |
| services/src/main/java/org/keycloak/authentication/requiredactions/VerifyEmail.java | Updates newly registered users’ restart cookies to return to login. |
| docs/documentation/upgrading/topics/changes/changes-26_7_0.adoc | Clarifies cross-browser behavior with the legacy registration switch. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #55287
Since #47538 (fix for #45568), verifying the email in another browser deliberately removes the original browser's authentication session, so an attacker waiting in that browser can't be logged in once the victim verifies. This PR keeps that and does not restore the 26.6 behaviour of the original browser completing the login. Instead, the original browser restarts to the login page within the client's original authorization request, so a native app still gets a code it can redeem with its PKCE verifier.
The 400 came from the restart cookie: registrations started with
/registrationsorprompt=createnever setKC_RESTART, unlike/auth.buildRegister()now sets it, afterAPP_INITIATED_FLOW, so an expired registration form restarts to the registration form, the same as a live restart (BrowserButtonsTest.appInitiatedRegistrationWithBackButton).Once the user is registered,
VerifyEmailrewrites the restart cookie to go to the login page. The action is set toAUTHENTICATEexplicitly, because the session is inREQUIRED_ACTIONSat that point and would otherwise restart to "page expired". The cookie carries only client notes, no user or auth notes, so the restarted browser gets nothing beyond the username the registrant typed. The username is pre-filled from thelogin_hintclient note thatRegistrationUserCreationalready sets; it is the username rather than the email, which always works on the login form and matches that existing note. This also applies when registration started from the login page.Decisions worth a look: if the session is lost after the user is created but before the verify-email page is shown (e.g. another required action comes first), the restart goes to the registration form rather than the login page. With organizations, the pre-filled username takes the user into identity-first, the same as a client-supplied
login_hint. The "Always set password on register form" switch never restored the old cross-browser behaviour, so the 26.7.0 upgrade note now says so.buildForgotCredential()has the same missing restart cookie; I left it out of scope.Tested with the new parameterized tests in
RegisterWithEmailVerificationTest(they fail withcookie_not_foundwithout the fix), and locally withRegisterTest,RequiredActionEmailVerificationTest,MultipleTabsLoginTest,BrowserButtonsTest,AppInitiatedRegistrationTest,OIDCAdvancedRequestParamsTest,RestartCookieTest,OID4VCAuthorizationCodeFlowWithPARTestand the WebAuthn registration tests.