Skip to content

Restart client-initiated registration after the email is verified in another browser - #55292

Open
gdsmith wants to merge 1 commit into
keycloak:mainfrom
gdsmith:issue-55287-registrations-restart-cookie
Open

gdsmith wants to merge 1 commit into
keycloak:mainfrom
gdsmith:issue-55287-registrations-restart-cookie

Conversation

@gdsmith

@gdsmith gdsmith commented Nov 17, 2026

Copy link
Copy Markdown

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 /registrations or prompt=create never set KC_RESTART, unlike /auth. buildRegister() now sets it, after APP_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, VerifyEmail rewrites the restart cookie to go to the login page. The action is set to AUTHENTICATE explicitly, because the session is in REQUIRED_ACTIONS at 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 the login_hint client note that RegistrationUserCreation already 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 with cookie_not_found without the fix), and locally with RegisterTest, RequiredActionEmailVerificationTest, MultipleTabsLoginTest, BrowserButtonsTest, AppInitiatedRegistrationTest, OIDCAdvancedRequestParamsTest, RestartCookieTest, OID4VCAuthorizationCodeFlowWithPARTest and the WebAuthn registration tests.

…another browser

Closes keycloak#55287

Signed-off-by: George McGinley Smith <george@mukuru.com>
@gdsmith
gdsmith marked this pull request as ready for review November 17, 2026 20:28
@gdsmith
gdsmith requested a review from a team as a code owner November 17, 2026 20:28
Copilot AI balanced review requested due to automatic review settings November 17, 2026 20:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Since 26.7.0, the original tab can't continue after the verification email is confirmed in another browser (400 "Restart login cookie not found")

2 participants