Repository navigation
Conversation
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
|
@mposolda @rmartinc could one of you take a look when you have a moment? It fixes the 400 "Restart login cookie not found" from #55287, which is a side effect of #47538. It keeps the original browser's session removal but the original browser now restarts to the login page in the client's original authorization request, with the username filled in, instead of hitting the 400. |
…another browser Closes keycloak#55287 Signed-off-by: George McGinley Smith <george@mukuru.com>
…ation restarts after verification in another browser The restart cookie set while a newly registered user waits for email verification now carries a marker. When the original browser restarts from it, and the registered user's email has since been verified, the login page shows "Your email address has been verified." as a success message, instead of the login timeout error and its EXPIRED_CODE event. A restart before the email is verified is still a timeout. Closes keycloak#55287 Signed-off-by: George McGinley Smith <george@mukuru.com>
…n another browser New option "Continue as registered user" on the Verify Email required action, off by default. When a user registers, then verifies their email in another browser, the login restarted in the browser used for the registration has the registered user already chosen, so it doesn't ask for the username again. The user still authenticates as the browser flow requires: with the combined form or the password form, they enter their password. Closes keycloak#55287 Signed-off-by: George McGinley Smith <george@mukuru.com>
2b979ad to
5b8bd39
Compare
|
I've rebased onto main and added two commits after trying this end to end in an iOS app. The restarted page said the login had timed out, which reads badly straight after verifying your email, so it now says the email is verified instead. The second is an opt-in Continue as registered user option on Verify Email, so the restart goes straight to the password rather than asking for the username again. |
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 aut 8000 h 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.The restarted login page used to say "Your login attempt timed out", which is wrong here and confusing for a user who has just verified their email. The cookie now also carries a client note marking a registration that is waiting for email verification. When the browser restarts from it and that user's email is verified, the login page shows the existing
emailVerifiedMessageas a success message, and noEXPIRED_CODEerror event is logged, since nothing expired. The marker is removed on that restart. If the email isn't verified yet (the session expired, or Keycloak restarted), it is still a timeout.The last commit adds an option Continue as registered user to the Verify Email required action, off by default. With it, the restart sets the registered user on the new authentication session, the same way re-authentication does, so an identity-first flow skips the username step and the combined form asks only for the password. It chooses the same user the pre-filled username would, and only when that user is enabled and has just verified their email; the browser flow still authenticates them as configured. It is opt-in because it changes what the restarted login looks like.
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. With Continue as registered user, the passkey shortcut inUsernamePasswordFormcan't skip the password, because a restarted session has no authenticated credentials yet. 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, and points to the new option.buildForgotCredential()has the same missing restart cookie; I left it out of scope.Tested with the parameterized tests in
RegisterWithEmailVerificationTest, which cover the three registration entry points, combined and identity-first browser flows, and the new option on and off, plus a test that a session lost before the email is verified still restarts as a timeout. Each commit's tests fail without that commit. On the rebased branch I also ranLoginTest,ResetPasswordTest,RefreshTokenTestandAcrAuthFlowTest, which go through the restart-from-cookie path. The first commit was also tested locally withRegisterTest,RequiredActionEmailVerificationTest,MultipleTabsLoginTest,BrowserButtonsTest,AppInitiatedRegistrationTest,OIDCAdvancedRequestParamsTest,RestartCookieTest,OID4VCAuthorizationCodeFlowWithPARTestand the WebAuthn registration tests.