Repository navigation
Description
Before reporting an issue
- I have read and understood the above terms for submitting issues, and I understand that my issue may be closed without action if I do not follow them.
Area
authentication
Bug Description
A user registers in browser A and is shown the "Email verification" page. They open the verification link in a different browser, B, and confirm it there. Up to 26.6, reloading the page in A then finished the login and redirected to the client with an authorization code. Since 26.7.0, A gets HTTP 400 "Restart login cookie not found" instead, and the login can't be completed there.
This is bad for email on a different device, but is a real problem in a native app where the app runs registration in an embedded WebView (browser A), and the mail app opens the link in system browser (browser B). B never redirects to the app, and from 26.7.0 the app's own tab can't continue either. The user has verified their email but isn't signed in anywhere, and has to sign in again from scratch. A theme can't recover the original tab, because only the client can start a new authorization request: it holds the PKCE verifier.
It happens with both registration variants in 26.7+:
- the new default, where the password is set after verification: B is taken through Update password, then A gets the 400
- with Always set password on register form switched on, which the 26.7.0 upgrading guide offers for the old behaviour: B just shows "Email address verified", and A still gets the 400
So the deprecated switch doesn't bring the old behaviour back for this case.
Version
26.8.2. Also reproduced on 26.7.0, 26.7.1 and nightly (999.0.0-SNAPSHOT, image built 2026-11-17).As in 26.6: once the email has been verified in browser B, reloading or continuing in browser A completes the login. A redirects to the client's redirect_uri with an authorization code, and the browser gets KEYCLOAK_IDENTITY and KEYCLOAK_SESSION. With the 26.7 default flow, where the password is set after verification, any of these would do: - A continues to the credential setup step itself - A restarts to a login page with the email as login_hint - A redirects to the client with an error the client can act on, rather than showing a dead-end 400
Regression
- The issue is a regression
Expected behavior
As in 26.6: once the email has been verified in browser B, reloading or continuing in browser A completes the login. A redirects to the client's redirect_uri with an authorization code, and the browser gets KEYCLOAK_IDENTITY and KEYCLOAK_SESSION.
With the 26.7 default flow, where the password is set after verification, any of these would do:
- A continues to the credential setup step itself
- A restarts to a login page with the email as
login_hint - A redirects to the client with an error the client can act on, rather than showing a dead-end 400
Actual behavior
Browser A, reload after B has verified (26.7.0, 26.7.1, 26.8.2, nightly):
HTTP 400, page: "We are sorry... Restart login cookie not found. It may have expired; it may have been deleted or cookies are disabled in your browser."- event:
type="CUSTOM_REQUIRED_ACTION_ERROR", error="cookie_not_found" - A still holds
AUTH_SESSION_IDandKC_AUTH_SESSION_HASH, so the cookies haven't gone. The authentication session they point to can't be continued any more.
How to Reproduce?
-
Start a stock Keycloak and a mail catcher on one network, for example
quay.io/keycloak/keycloak:26.8.2 start-dev --import-realmandaxllent/mailpit, and import this realm:{ "realm": "repro", "enabled": true, "registrationAllowed": true, "registrationEmailAsUsername": true, "verifyEmail": true, "smtpServer": { "host": "mailpit", "port": "1025", "from": "keycloak@example.com" }, "clients": [ { "clientId": "native-app", "publicClient": true, "standardFlowEnabled": true, "redirectUris": ["com.example.app:/auth"], "attributes": { "pkce.code.challenge.method": "S256" } } ] } -
Browser A: open
http://localhost:8080/realms/repro/protocol/openid-connect/registrations?client_id=native-app&response_type=code&scope=openid&redirect_uri=com.example.app:/auth&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM&code_challenge_method=S256
and submit the form. A shows "Email verification". -
Browser B (another browser or a private window): open the link from the verification email, then "Click here to proceed". On 26.7+ with the default flow, set a password when asked.
-
Browser A: reload the "Email verification" page.
- 26.4.7, 26.5.0, 26.6.0: redirects to
com.example.app:/auth?...&code=... - 26.7.0, 26.7.1, 26.8.2, nightly: 400 "Restart login cookie not found"
- 26.4.7, 26.5.0, 26.6.0: redirects to
-
Optional: on 26.7+, turn on Always set password on register form (registration flow, Password validation) and repeat. The result is still 400.
Steps were run with two independent curl cookie jars against each image. The same behaviour shows in an iOS app's WKWebView with Safari opening the email link.
Anything else?
- The 26.7.0 upgrading guide's "Verify email required before credentials setup during user self-registration" section offers Always set password on register form for the old behaviour, and says it is deprecated and may be removed. For this case it doesn't restore 26.6 behaviour, so there's currently no configuration that does.
- Related, earlier reports of the cross-browser case: Email Verification Works in the Same Browser but Fails Across Different Browsers #31185, discussion Keycloak 24: linking of Keycloak-account with identity-provider does not work in different browsers ( as expected ) #29087.
- Third-party themes are already working around the dead end on 26.7.x and 26.8.x: login: verify-email from another browser ends on a dead-end page reesing322/soccerproject-keycloak-theme#24 and KEYCLOAK-66 MongoDB based backend and performance testsuite #60, and PR KEYCLOAK-84 form for managing totp authentificators #67. They can only send users to the client's landing page.
- RFC 8252 recommends the system browser for native apps, but email links still often open somewhere else: mail apps' in-app browsers, a different default browser, or another device. Before 26.7 the original tab recovered from that; now it doesn't.
Metadata
Metadata
Assignees
Labels
Type
Fields
Projects
- StatusShow more project fieldsOpen
Activity