When a relying party initiates an OIDC authorization request with
prompt=none and Zitadel has no usable session for the request, the Login V2
flow violates OpenID Connect Core 1.0 §3.1.2.6 (Authentication Error
Response). Two distinct broken paths in
apps/login/src/lib/server/flow-initiation.ts:
- Sessions exist but none is valid for the auth request (e.g. the
end-user explicitly signed out at Zitadel, leaving stale entries in the
multi-session cookie): the handler returns
NextResponse.json({ error: "No active session found" }, { status: 400 }). Becauseprompt=noneis typically initiated by a top-level navigation, the browser renders this JSON response directly — the user sees an unstyled Zitadel page reading "No active session found" with no way back to the originating app. - No sessions at all: the handler falls through the outer
if (authRequest && sessions.length)guard into the bottom branch, which redirects the user to/loginnameand displays the interactive login UI — the exact behaviourprompt=noneforbids.
In both cases, the relying party never receives the spec-mandated redirect
to its redirect_uri carrying error=login_required, so silent re-auth
flows dead-end at Zitadel and silent SSO across applications cannot recover
gracefully.
Replace both broken short-circuits with a createCallback call using the
error callback kind, which already exists in the backend:
const { callbackUrl } = await createCallback({
serviceConfig,
req: create(CreateCallbackRequestSchema, {
authRequestId: requestId.replace("oidc_", ""),
callbackKind: {
case: "error",
value: create(AuthorizationErrorSchema, {
error: ErrorReason.LOGIN_REQUIRED,
}),
},
}),
});
return NextResponse.redirect(callbackUrl);Concrete edits in apps/login/src/lib/server/flow-initiation.ts:
- Hoist the
Prompt.NONEcheck above the outerif (authRequest && sessions.length)guard so that the no-sessions case is handled the same way as the no-valid-session case rather than falling through to interactive login. - Inside the
Prompt.NONEbranch, replacenoSessionResponse(the JSON 400) with thelogin_requiredcallback redirect above. Both the "noselectedSession" and the "no cookie/token" early returns funnel through the same helper.
The Go backend already does the right thing: CreateCallback with the
error case dispatches to failAuthRequest, which calls
errorReasonToOIDC and builds a spec-compliant URL via
oidc.CreateErrorCallbackURL (see internal/api/grpc/oidc/v2/oidc.go).
This change is purely a frontend fix to actually use that path.
- New tests in
apps/login/src/lib/server/flow-initiation.test.tscovering threeprompt=nonescenarios:- no sessions in the cookie at all,
- sessions present but
findValidSessionreturns none / the cookie lacks a token (post-logout), - a valid session is available (regression — must still produce the success callback redirect).
- Each test asserts the response is a redirect (302) to a URL whose query
string contains
error=login_required, rather than a JSON 400 or a redirect to/loginname.
- OpenID Connect Core 1.0 §3.1.2.6 — Authentication Error Response: https://openid.net/specs/openid-connect-core-1_0.html#AuthError
- The proto schema at
proto/zitadel/oidc/v2/authorization.protodocumentsAuthorizationErrorwith an explicit reference to the spec section above, and definesERROR_REASON_LOGIN_REQUIRED = 9. TheCreateCallbackRequest.callback_kindoneof inproto/zitadel/oidc/v2/oidc_service.protowas designed for exactly this case. - Discussion #10469 — "How to Implement Silent Login in Second App With
Zitadel Session Check": maintainers recommend
prompt=nonefor cross-application silent re-auth. This PR makes that recommendation actually work when the Zitadel session is gone. - Discussion #3959 — clarifies that iframe-based silent check is
intentionally unsupported (Zitadel sets
X-Frame-Options: DENY) and that redirect/popupprompt=noneis the supported path. This PR fixes that supported path. - Reproduction: configure any OIDC client, sign in via Login V2, then sign
out at Zitadel, then have the client initiate a top-level navigation to
/oauth/v2/authorize?...&prompt=none. Observe the unstyled "No active session found" page rather than a redirect back toredirect_uriwitherror=login_required.