Skip to content

feat(api): sign in to an OAuth client as its authorization request asks - #3568

Merged
wim07101993 merged 14 commits into
mainfrom
feat/2795-authorize-request-login
Dec 3, 2026
Merged

wim07101993 merged 14 commits into
mainfrom
feat/2795-authorize-request-login

Conversation

@wim07101993

Copy link
Copy Markdown
Member

Context

Summary

The authorization endpoint and POST /flows now answer an authorization request the way it asks, and answer it without a page when the browser is already signed in. Five commits, one per part, to review in order:

  • A cross-site POST to the authorization endpoint is answered with a 303 to the same GET.
    • A browser sends no SameSite=Lax cookie with another site's POST. Without them, the endpoint could not count or expire the binding cookies the browser held.
    • The same applies to a POST without Sec-Fetch-Site. A POST from the issuer's own site is unchanged.
    • A request stays open 15 minutes from the redirect, however long its flow takes.
  • Each flow has a cookie of its own, _zflow_{flow_id}, so two sign-ins in one browser no longer end each other.
    • A browser keeps at most three: POST /flows deletes the oldest the request carried beyond that.
    • A pivot or a pop moves the cookie to the new id.
    • The _zflow cookie parameter leaves the spec. A new x-zitadel-cookie extension names the cookie instead, and @zitadel/api's operations export carries it.
    • <zitadel-login> starts over on a 404 or 410. @zitadel/testing's seedSession carries the new cookie.
  • The request shapes the sign-in. The endpoint stores prompt, max_age and login_hint.
    • POST /flows admits the request before it resolves a definition.
    • prompt=create starts at registration, or signs in when the project has none.
    • login_hint pre-fills the identifier and replaces hint.login_name. It is never submitted for the user, and hint.login_name now pre-fills too.
    • A first-party client's prompt=consent gets the consent step instead of a refusal.
  • A live session answers without a page.
    • POST /flows reads the browser's session cookie through a new WithBrowserSessionCookie middleware.
    • The session must be active and belong to the project, its user active, with a credential proved within max_age, and the client must need no consent. Then the first step is the terminal redirect with the code, with no handoff and no flow cookie.
    • prompt=login, prompt=select_account and a client that needs consent still sign the person in.
    • prompt=none is now accepted. When no session can answer, the client gets login_required or consent_required at its redirect URI, and the request stays open.
  • Every response names the client that asks.
    • FlowResponse.client holds client_id, application_id, name, redirect_host, document_host and first_party, read once at admission and kept in the flow state.
    • The request's application replaces hint.app_id when the definition is resolved.
    • A client that is gone by then refuses the request with flow.auth_request_invalid.

Validation

On the rebased branch (on 589027c17):

  • turbo run check-generate --filter=@zitadel/server --only
  • go vet ./... and go test ./internal/... in apps/api
  • go test -tags sqlite_integration -run 'TestOAuthSignIn|TestSignIn|TestFlow|TestAuthorize' ./internal/api/integration_test/
  • node scripts/check-pr-title.mjs

Per part, before the rebase:

  • go test -tags sqlite_integration ./internal/api/integration_test/ (the whole suite)
  • -tags postgres_integration -run 'TestOAuthSignIn|TestSignIn|TestFlow'
  • -tags spanner_integration -run 'TestOAuthSignIn|TestSignIn'
  • The storage and migration tests on all three dialects, for the new auth_requests columns
  • node scripts/lint-openapi.mjs (0 errors)

New end-to-end tests in oauth_sign_in_test.go:

  • TestOAuthSignInAsTheRequestAsks: login_hint, prompt=consent, prompt=create.
  • TestOAuthSignInFromALiveSession: answered at once, with the code redeemed for a token. Also max_age, prompt=none with and without a session, prompt=login, and consent_required.
  • Every OAuth sign-in response is checked for its client.

Not run:

  • The TypeScript checks for @zitadel/components, @zitadel/testing and @zitadel/cli (the cookie part). This checkout lacks knip, unplugin-dts and @lit/task, so CI is the first run.
  • The full Postgres and Spanner suites.
  • A browser against a running server.

Release notes / changeset

  • .changeset/authorize-cross-site-post.md: @zitadel/server patch.
  • .changeset/flow-cookie-per-flow.md: @zitadel/server and @zitadel/api minor; @zitadel/components, @zitadel/testing and @zitadel/cli patch.
  • .changeset/auth-request-prompt-login-hint.md: @zitadel/server minor, @zitadel/api patch.
  • .changeset/auth-request-live-session.md: @zitadel/server minor.
  • .changeset/flow-requesting-client.md: @zitadel/server minor, @zitadel/api patch.

Notes

  • Breaking for a non-browser client of the flow API: the _zflow cookie parameter is gone from the generated clients. It sends back the _zflow_{flow_id} cookie the last response set.
  • Rebase: apps/cli/tests/unit/lib/orca/patchers/rule/vite-support.test.ts took main's version. The cookie part only renamed _zflow in a test that main has since removed.
  • Follow-ups:
    • ADR 081 §8.1: refuse anything but a top-level navigation at the authorization endpoint, with prompt=none exempt. This matters more now that prompt=none is accepted.
    • Consent on a live session without signing in again.
    • The anonymous session Start creates before a live session answers is never used. It expires.
    • client in <zitadel-login>'s template context and on zitadel-flow-step. That changes the SDKs' event contract, so it comes on its own.
    • A logo and app branding need an application document field and branding per app or team.

🤖 Generated with Claude Code

A browser sends no SameSite=Lax cookie with another site's POST, so the
binding cookie limit could not count or expire the cookies it held. The
authorization endpoint now answers such a POST, or one with no
Sec-Fetch-Site, with a 303 to the same request as a GET, which sends
them. A POST from the issuer's own site is unchanged.

An authorization request now stays open 15 minutes from the redirect,
however long its flow takes. The flow API description, the bundled
OpenAPI spec, the generated Go code and ADR 081 (amended 2026-12-02)
say so.

Adds a server patch changeset. The cross-site test case that carried
TODO(#2795) is replaced by same-origin and same-site cases, and a test
covers the redirect.
Each flow now has its own cookie, `_zflow_{flow_id}`, in place of one
shared `_zflow`, so two sign-ins in one browser no longer end each
other. A browser keeps at most three flow cookies: starting a flow
deletes the oldest ones the request carried beyond that. A response
whose flow id changes deletes the cookie under the old id.

The step and submit operations name the cookie with a new
`x-zitadel-cookie` extension, documented in the OpenAPI AGENTS.md. The
flow-cookie parameter is removed. A submit without the cookie answers
401 `flow.cookie_invalid`; a GET of another flow's id answers 404
`flow.not_found`.

The bundled spec, the generated Go code and the flow descriptions
follow. The server mounts `api.WithFlowCookies`, and the integration
helper mounts it too.
The flow now reads the request's prompt and login_hint. A login_hint
pre-fills the identifier field but is no longer submitted for the
user, so a crafted link starts no identifier lookup. prompt=create
starts the flow at the project's registration, and prompt=consent adds
the consent step for the project's own client too.

The prompt is stored with the auth request in migrations 000063 for
Postgres, 000067 for Spanner and 000050 for SQLite. The flow service
admits the request through AdmitAuthRequest.

The OpenAPI descriptions, the bundled spec, the generated Go code, ADR
081 and the flow engine design note follow. Adds a changeset.
When the browser's session cookie holds an active session of the project,
signed in to an active user within the request's max_age, and the client
needs no consent, an authorization request ends at once in a redirect
that carries the code. No handoff_token is issued, since the browser
already holds the session. prompt=login and prompt=select_account still
ask for a sign-in. prompt=none answers login_required, or
consent_required when the client needs consent.

The createFlow response carries that terminal step with complete:
redirect and sets no flow cookie. The create-flow request description,
the createFlow error responses and the flow endpoint description say so.
The createFlow error responses also list app.client_not_found,
authreq.code_not_issued, clientdoc.invalid, clientdoc.not_admitted,
clientdoc.unavailable, dep.not_found, flow.consent_scopes_invalid and
sess.not_found.

The bundled spec and the generated Go code follow. The integration
helper mounts api.WithBrowserSessionCookie. Adds a changeset.
A flow started with auth_request_id now names the OAuth client whose
authorization request it answers. Every response carries it as `client`:
the client's id, application, name, redirect host, metadata document host
and first_party flag. Other flows carry no `client`.

The flow is scoped to the request's application instead of the app_id
the page hints, and a client of no application hints none.
AdmitAuthRequest returns the admitted request with its client, and the
flow state keeps that client from the start. NewFlowService takes the
client directory to read it.

The OpenAPI spec gains the flow-client schema and the client property,
and the app_id description changes. The bundled spec and generated Go
code follow. ADR 081, the flow engine design note and a changeset say so.
@vercel

vercel Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cloud Ready Ready Preview Dec 3, 2026 8:03am UTC

Request Review

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

🦋 Changeset detected

Latest commit: a3d4ef6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
@zitadel/server Minor
@zitadel/api Minor
@zitadel/components Minor
@zitadel/testing Minor
@zitadel/cli Minor
@zitadel/config Minor
@zitadel/sdk-angular Minor
@zitadel/sdk-core Minor
@zitadel/sdk-next Minor
@zitadel/sdk-nuxt Minor
@zitadel/sdk-qwik Minor
@zitadel/sdk-react Minor
@zitadel/sdk-solid Minor
@zitadel/sdk-svelte Minor
@zitadel/sdk-tanstack-start Minor
@zitadel/sdk-vue Minor
@zitadel/cloud Patch
@zitadel/client-sdk-contract Patch
@zitadel/sdk-qwik-router Minor
@zitadel/sdk-solid-start Minor
@zitadel/sdk-sveltekit Minor
@zitadel/server-sdk-contract Patch
@zitadel/server-darwin-arm64 Minor
@zitadel/server-darwin-x64 Minor
@zitadel/server-linux-arm64 Minor
@zitadel/server-linux-x64 Minor
@zitadel/server-win32-x64 Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@wim07101993
wim07101993 marked this pull request as ready for review December 2, 2026 11:31

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.

🟡 Changes recommended

Critical flow defects let existing sessions bypass explicitly requested reauthentication and skip account registration, with additional registration-lookup and benchmark-cookie issues unresolved.

4 open issues
What changed in this PR

Implements the server-side OAuth sign-in behavior for customer-hosted login, advancing #2795 and #1425. Authorization requests now shape flows, eligible sessions can answer immediately, and responses identify the requesting client.

Changes:

  • Supports request prompts, login hints, session freshness, and silent authorization responses.
  • Introduces per-flow cookies and cross-site authorization POST redirects.
  • Updates API contracts, clients, tests, documentation, and release notes.
File Description
tools/​bench/​k6module/​doer.go Sends journey flow cookies.
tools/​bench/​harness/​ops.go Carries dynamically named flow cookies.
tools/​bench/​harness/​ops_test.go Updates cookie fixtures.
tools/​bench/​harness/​fixtures.go Attaches flow cookies to requests.
packages/​testing/​tests/​unit/​session.test.ts Tests per-flow cookie forwarding.
packages/​testing/​src/​session.ts Tracks per-flow cookies.
packages/​testing/​AGENTS.md Updates cookie guidance.
packages/​sdk-core/​src/​__tests__/​middleware.test.ts Updates proxy cookie fixtures.
packages/​go/​api/​oas_parameters_gen.go Removes fixed cookie parameters.
packages/​components/​src/​orchestrator/​zitadel-login.ts Adjusts expired-flow recovery.
packages/​components/​src/​orchestrator/​zitadel-login-sso.spec.ts Updates recovery expectations.
packages/​components/​src/​orchestrator/​api-client.ts Updates cookie comments.
packages/​components/​README.md Documents per-flow cookies.
packages/​api/​scripts/​operations.ts Exposes operation cookie metadata.
docs/​design/​flowengine/​flow-engine.md Documents request-driven flows.
docs/​adrs/​README.md Summarizes ADR amendments.
docs/​adrs/​081-customer-hosted-login-and-oidc-provider.md Records authorization behavior decisions.
docs/​adrs/​073-session-cookie-per-project.md Records per-flow cookie isolation.
apps/​docs/​content/​docs/​reference/​api/​flows/​index.mdx Documents cookie lifecycle.
apps/​cli/​tests/​unit/​lib/​backend/​services/​operation.test.ts Updates cookie restriction assertion.
apps/​cli/​src/​lib/​backend/​services/​operation.ts Uses operation cookie metadata.
apps/​api/​internal/​storage/​stmttest/​auth_request_test.go Tests stored authorization preferences.
apps/​api/​internal/​storage/​dialect/​sqlite/​migration/​sql/​000050_auth_request_prompt.sql Adds authorization preference columns.
apps/​api/​internal/​storage/​dialect/​sqlite/​auth_request.go Persists authorization preferences.
apps/​api/​internal/​storage/​dialect/​spanner/​migration/​sql/​000067_auth_request_prompt.sql Adds authorization preference columns.
apps/​api/​internal/​storage/​dialect/​spanner/​auth_request.go Persists authorization preferences.
apps/​api/​internal/​storage/​dialect/​postgres/​migration/​sql/​000063_auth_request_prompt.sql Adds authorization preference columns.
apps/​api/​internal/​storage/​dialect/​postgres/​auth_request.go Persists authorization preferences.
apps/​api/​internal/​service/​metrics_test.go Updates service construction.
apps/​api/​internal/​service/​flow.go Admits requests and checks session eligibility.
apps/​api/​internal/​service/​flow_auth_request.go Handles consent and silent refusals.
apps/​api/​internal/​service/​flow_auth_request_test.go Tests consent and refusal behavior.
apps/​api/​internal/​service/​client_directory.go Supplies requesting application IDs.
apps/​api/​internal/​oauth/​server.go Wires cross-site POST middleware.
apps/​api/​internal/​oauth/​client.go Removes obsolete first-party state.
apps/​api/​internal/​oauth/​authorize.go Stores preferences and redirects cross-site POSTs.
apps/​api/​internal/​flowengine/​state.go Stores client metadata and login hints.
apps/​api/​internal/​flowengine/​state_machine.go Enables immediate authorization responses.
apps/​api/​internal/​flowengine/​render_test.go Tests identifier prefilling.
apps/​api/​internal/​flowengine/​mock/​flowengine.mock.go Adds refusal service mock.
apps/​api/​internal/​flowengine/​fields.go Prefills identifiers from hints.
apps/​api/​internal/​flowengine/​auth_request.go Answers requests without sign-in.
apps/​api/​internal/​flowengine/​auth_request_test.go Tests immediate responses and client retention.
apps/​api/​internal/​domain/​auth_request.go Defines request preferences and lifetime.
apps/​api/​internal/​api/​legacy_flow_path_test.go Removes fixed-cookie setup.
apps/​api/​internal/​api/​integration_test/​user_migration_test.go Migrates flow cookie transport.
apps/​api/​internal/​api/​integration_test/​user_create_policy_test.go Migrates flow cookie transport.
apps/​api/​internal/​api/​integration_test/​sso_submit_flow_test.go Uses per-flow cookie names.
apps/​api/​internal/​api/​integration_test/​sso_resolution_flow_test.go Migrates flow cookie transport.
apps/​api/​internal/​api/​integration_test/​sso_providers_flow_test.go Migrates flow cookie transport.
apps/​api/​internal/​api/​integration_test/​sso_conflict_flow_test.go Migrates flow cookie transport.
apps/​api/​internal/​api/​integration_test/​sso_callback_flow_test.go Uses per-flow cookie names.
apps/​api/​internal/​api/​integration_test/​signup_protection_test.go Migrates signup cookie transport.
apps/​api/​internal/​api/​integration_test/​sign_up_events_test.go Migrates flow cookie transport.
apps/​api/​internal/​api/​integration_test/​registration_flow_test.go Migrates registration cookie transport.
apps/​api/​internal/​api/​integration_test/​project_test.go Extends the flow service stub.
apps/​api/​internal/​api/​integration_test/​policy_test.go Migrates flow cookie transport.
apps/​api/​internal/​api/​integration_test/​password_flow_test.go Migrates password-flow cookie transport.
apps/​api/​internal/​api/​integration_test/​passkey_upsell_flow_test.go Migrates passkey-flow cookie transport.
apps/​api/​internal/​api/​integration_test/​passkey_signup_protection_test.go Migrates signup cookie transport.
apps/​api/​internal/​api/​integration_test/​passkey_flow_test.go Updates cookie transport and extraction.
apps/​api/​internal/​api/​integration_test/​oauth_refresh_test.go Preserves flow cookie names.
apps/​api/​internal/​api/​integration_test/​oauth_client_document_test.go Preserves flow cookie names.
apps/​api/​internal/​api/​integration_test/​identifier_scope_flow_test.go Migrates flow cookie transport.
apps/​api/​internal/​api/​integration_test/​helpers/​server.go Wires browser-cookie middleware.
apps/​api/​internal/​api/​integration_test/​helpers/​flow.go Supplies client directory dependency.
apps/​api/​internal/​api/​integration_test/​helpers/​client.go Adds contextual flow-cookie transport.
apps/​api/​internal/​api/​integration_test/​flow_submit_refusal_test.go Preserves flow cookie names.
apps/​api/​internal/​api/​integration_test/​flow_origin_test.go Updates cookie helpers and middleware.
apps/​api/​internal/​api/​integration_test/​flow_legacy_path_test.go Tests legacy routes with named cookies.
apps/​api/​internal/​api/​integration_test/​event_user_filter_test.go Migrates flow cookie transport.
apps/​api/​internal/​api/​integration_test/​combined_flow_test.go Migrates combined-flow cookie transport.
apps/​api/​internal/​api/​integration_test/​claim_test.go Migrates claim-flow cookie transport.
apps/​api/​internal/​api/​generated/​oas_unimplemented_gen.go Regenerates operation documentation.
apps/​api/​internal/​api/​generated/​oas_server_gen.go Regenerates handler contract documentation.
apps/​api/​internal/​api/​generated/​oas_parameters_gen.go Removes fixed-cookie decoding.
apps/​api/​internal/​api/​generated/​oas_handlers_gen.go Updates generated parameter handling.
apps/​api/​internal/​api/​flow.go Applies request preferences and client metadata.
apps/​api/​internal/​api/​flow_cookie.go Implements per-flow cookie lifecycle.
apps/​api/​internal/​api/​error_handler_test.go Removes obsolete cookie-decoding test.
apps/​api/​internal/​api/​cookie_secure_internal_test.go Updates cookie helper calls.
apps/​api/​cmd/​server/​server.go Wires services and cookie middleware.
apps/​api/​api/​openapi/​endpoints/​flows/​submit/​methods.yaml Declares dynamic submit cookies.
apps/​api/​api/​openapi/​endpoints/​flows/​session/​methods.yaml Declares dynamic read cookies.
apps/​api/​api/​openapi/​endpoints/​flows/​methods.yaml Documents immediate completion and cookies.
apps/​api/​api/​openapi/​endpoints/​flows/​createFlow-error-response.yaml Expands creation error contract.
apps/​api/​api/​openapi/​components/​parameters/​flow-id.yaml Documents ID-based cookie naming.
apps/​api/​api/​openapi/​components/​parameters/​flow-cookie.yaml Removes fixed cookie parameter.
apps/​api/​api/​openapi/​components/​headers/​set-cookie-flow.yaml Documents cookie rotation and eviction.
apps/​api/​api/​openapi/​components/​flows/​flow-submit-request.yaml Updates cookie documentation.
apps/​api/​api/​openapi/​components/​flows/​flow-response.yaml Adds requesting-client metadata.
apps/​api/​api/​openapi/​components/​flows/​flow-hint.yaml Documents hint precedence.
apps/​api/​api/​openapi/​components/​flows/​flow-client.yaml Defines requesting-client schema.
apps/​api/​api/​openapi/​components/​flows/​create-flow-request.yaml Documents authorization-driven behavior.
apps/​api/​api/​openapi/​AGENTS.md Defines dynamic-cookie extension guidance.
.changeset/​flow-requesting-client.md Announces client metadata support.
.changeset/​flow-cookie-per-flow.md Announces cookie contract migration.
.changeset/​authorize-cross-site-post.md Announces cross-site POST handling.
.changeset/​auth-request-prompt-login-hint.md Announces prompt and hint support.
.changeset/​auth-request-live-session.md Announces live-session authorization.

Review effort: Balanced

Comment thread apps/api/internal/service/flow.go Resolved
Comment thread apps/api/internal/service/flow.go Resolved
Comment thread apps/api/internal/api/flow.go Resolved
Comment thread tools/bench/harness/ops.go Resolved

@IAM-marco IAM-marco 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.

Thanks for this, the five parts are easy to follow commit by commit. I am requesting changes for the three comments about who gets a code without a page. The rest is smaller.

Code review

Six comments are inline.

Who gets a code without a page (please look at these first)

  • Bug, service/flow.go: a live session answers the request whatever purpose the page asked for, so a register or reauth page is skipped.
  • Bug, flowengine/auth_request.go: a first-party client without a secret gets a code with no action by the person, also on a loopback redirect, where any local program can receive it.
  • History note, service/flow_auth_request.go: a prompt=none refusal leaves the request open, so the same request can get an error first and a code later.

Contract and structure

  • Comment guidance, create-flow-request.yaml: "Such a flow" now describes the flow that ends at once, and promises a code and a handoff_token it does not have.
  • Guideline note, api/flow.go: the handler picks the prompt=create definition and builds the prompt=none terminal step, which architecture.md gives to the service and the engine.
  • Guideline note, flow-response.yaml: the API mock sends no client on a flow started with auth_request_id.

Tally: 6 findings: 2 bugs, 1 history note, 1 comment guidance, 2 guideline notes.
Worst issue: the code for a first-party client without a secret on a loopback redirect.

Ponytail

A review of the branch at 5e6ebd9a6 for three things: code that could be smaller, risky code without a test, and cost under load. It read the callers and the tests, not only the diff. Load assumed: many users and several server processes.

Nine comments are inline. None of them blocks the PR on this axis.

Worth fixing (4)

  1. apps/api/cmd/server/server.go: no test checks that the server's own chain has the two new cookie middlewares.
  2. oauth_sign_in_test.go: eight integration subtests repeat a rule that a lower test already proves.
  3. service/flow.go: sessionMayAnswer has a second copy of the "active user" query.
  4. domain/auth_request.go: prompt=none now stores a row per silent check, and nothing deletes expired rows yet (a note for #3169, no code asked).

Optional (5)

  1. service/flow.go: RefuseAuthRequest copies FlowAuthRequests.Refuse.
  2. api/flow_cookie.go: two middlewares where one would do.
  3. flowengine/auth_request.go: a sign-in without a page reads the same request row four times.
  4. oauth_sign_in_test.go: the start and token test helpers are copied.
  5. api/flow.go: a third hand copy of the rule for a token the server could not judge.

Tally: 9 findings, 4 worth fixing, 5 optional. About 120 lines could go, most of them tests.
Worst issue: the missing test for the server's middleware chain (comment 1). Without it, sign-in from a live session can stop working on a deployed server while every Go test stays green.

One note on the PR description. The follow-up "The anonymous session Start creates before a live session answers is never used. It expires." no longer matches the code. Start now asks the engine first and creates a session only when a sign-in is needed (

// A flow that ends as it starts runs against no session of its own, so
// a client that renews silently leaves none behind.
result, answered, err := s.stateMachine.AnswerWithoutSignIn(ctx, in)
if err != nil || answered {
return result, err
}
sessionID, err := s.resolveFlowSession(ctx, req)
if err != nil {
return flowengine.StepResult{}, err
}
audit.BindPublicRequest(ctx, req.Definition.ProjectID, flowID, sessionID)
in.Session = flowengine.SessionRef{ID: sessionID}
). That bullet can go.

Not checked: no test or build was run for this review. The TypeScript changes were read as a diff only.

Comment thread apps/api/cmd/server/server.go Resolved
Comment thread apps/api/internal/service/flow.go Resolved
Comment thread apps/api/internal/service/flow.go Resolved
Comment thread apps/api/internal/api/flow.go Resolved
POST /flows for an auth_request_id now reads the browser's session
cookie. An active session of the project answers a login whose client
needs no consent, so the flow ends in a terminal redirect with the code
and no handoff_token or flow cookie. prompt=login, prompt=select_account
and prompt=create still show a page, and so does any consent-requiring
client or non-login purpose.

prompt=none is accepted at /authorize. When no session can answer, the
flow ends at the client's redirect URI with login_required, or
consent_required when the client needs consent. A prompt=none request
that no flow definition resolves gets login_required the same way.
A public client with no secret, answered at a loopback address or a
custom scheme, can be presented by any program on the device. Its
request now gets the sign-in page even when a session is live.
AdmittedAuthRequest carries ClientIdentityAssured, set when the client
holds a secret or its answer goes to an https address that is not
loopback (RFC 8252 section 8.6).

A prompt=none request for such a client ends at login_required, as it
does when no session can answer.

The OpenAPI description, the bundled spec, the generated Go code and ADR
081 say so, and the changeset is reworded to match. The flow tests cover
an unassured client with and without prompt=none.
A refused request stayed open, so a reload of the login page after the
person signed in elsewhere could send a code for a state the client had
already heard refused. Refusing now expires the request at once, through
a new ExpireAuthRequest statement in the Postgres, Spanner and SQLite
dialects. A later flow for it is refused with flow.auth_request_invalid.

The flow service and the authorization endpoint share the refusal, so
both spend the request the same way. The OpenAPI description, the
bundled spec, the generated Go code, ADR 081 and the changeset follow.
Tests cover the expiry in the statement layer and the refusal in the
service.
The handler no longer builds the prompt=none refusal itself. When no
definition serves an authorization request, it passes the request to
Start without a definition. Start asks the engine's AnswerWithoutSignIn
for the refusal, so the refusal and the state it returns come from one
place.

AnswerWithoutSignIn accepts a nil definition only for a refusal. A
request with a live session, or one without prompt=none, is an error.
The state names the request's project and client, with no definition
to read.

AuthRequestRef gains ProjectID, the project the request belongs to,
which the engine answers in when no definition serves it.

FlowService.RefuseAuthRequest is removed from the interface and the
service, along with its handler test fake. The flow engine architecture
note describes the new path.

Tests cover the engine's refusal and its rejection of other requests,
and Start's refusal. The handler test now checks that Start receives
the request without a definition.
Move the authorization request, the flow start and the token exchange
into signInFixture methods, so the sign-in and live-session tests share
one copy. The flow step decodes purpose, fields and actions too.

Drop the live-session subtests for max_age, prompt=none, prompt=login,
prompt=create, a consent-requiring client, an unknown flow definition
and the session count. The service and engine tests cover those rules.
The live-session test keeps only what the whole path shows, and its doc
comment says so.

@IAM-marco IAM-marco 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.

Thanks for the fixes. I rechecked the review comments at a3d4ef6 and the changes I asked for are in.

One thing before merging: the branch conflicts with main, so ci did not run on this commit. Its last run was on 5e6ebd9. Could you please merge main and let ci run?

The conflicting files are:

  • apps/api/api/openapi/AGENTS.md
  • apps/api/api/openapi/bundled/openapi.json
  • apps/api/internal/service/client_directory.go
  • apps/api/internal/service/flow_auth_request.go
  • apps/api/internal/service/flow_auth_request_test.go
  • apps/cli/src/lib/backend/services/operation.ts
  • packages/api/scripts/operations.ts

Please take care with flow_auth_request.go and client_directory.go. They hold the change that spends a refused request and the Public flag that decides whether a live session may answer.

Resolve the overlap with remembered consent (#3574): keep main's prompt
column, stored space-separated, and move this branch's max_age and
login_hint migration after main's. A first-party client is asked for
consent on prompt=consent or a scope that always needs it, one rule
decides whether a client's identity is assured, and a live session
answers with a consent the person already gave.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Dec 3, 2026

Copy link
Copy Markdown

@wim07101993 is attempting to run Vercel CI for a commit to the zitadel team on Vercel, but is not a member of this team.

This branch was successfully deployed

1 active deployment
Preview — 209a5b83 Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Login: answer authorization requests in the customer-hosted login

4 participants