Repository navigation
feat: let people choose which scopes to grant on the OAuth consent screen - #3543
Conversation
The consent step offers the requested scopes as a choice: each carries its resource, what it lets the client do (read, change, delete, offline) and whether it starts ticked. Reading and staying connected start ticked; every change and delete takes a deliberate tick. accept names the granted scopes in fields.scopes. The engine checks them against the request (a subset, with at least one API scope; granting nothing is a deny) and the code is issued for them only, in the same write that stores the code. An accept without fields.scopes grants the preselected ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmRq5Pvdwoc568KP9Go
<zl-consent> offers the step's scopes as native checkboxes, grouped by resource, with presets (Read only, Everything requested) and staying connected as a choice of its own. Reading and staying connected start ticked; every change and delete takes a deliberate tick. Its value is the granted scopes, which an allow submits as fields.scopes, and allow stays disabled until an API scope is ticked: granting none is a deny. Every scope a person's platform token can carry, and its resource, gets a consent text in en, de and it, and a server test fails a scope without one. The shipped designs pass the choice, and the mandatory gate gives it to a template that renders the summary without it. The API mock classifies the scopes and refuses an allow the engine refuses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmRq5Pvdwoc568KP9Go
The consent step offers the requested scopes as a choice: reading starts ticked, changes and deletes take a deliberate tick, staying connected is its own choice, and granting nothing is a deny. ADR 092, the component capability map, the design guide's parts and the components README follow; the pending consent changeset says what the person now chooses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmRq5Pvdwoc568KP9Go
…claration The consent step renders what the server sends for whichever API a request names: each scope's group and access, which an API may declare and which otherwise follow from the name <group>.<verb>. The wire field resource of a consent scope is now group, and its name's key consent.group.<group>. The words for an API's scopes come from the app that asks for consent, through locales, like every other login text: the login component ships none. The console brings the Zitadel API's, as a customer's app brings its own, and the server's tests require them for every scope a person's token can carry and hold the spec's scope names to the naming rule. ADR 082's amendment and the pending changeset follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmRq5Pvdwoc568KP9Go
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
🦋 Changeset detectedLatest commit: c4a3e08 The changes in this PR will be included in the next version bump. This PR includes changesets to release 27 packages
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 |
There was a problem hiding this comment.
🟡 Changes recommended
The mock bypasses scope validation when fields.scopes is omitted, while the login UI incorrectly blocks requests containing only offline_access, creating inconsistent behavior with the server.
2 open issues
What changed in this PR
Adds selective OAuth consent to Zitadel’s sign-in flow, letting people limit requested permissions before an MCP or other OAuth client receives tokens.
Changes:
- Validates chosen scopes and stores the narrowed grant with the authorization code.
- Adds grouped scope checkboxes, presets, an offline-access toggle, and localized console labels.
- Updates API contracts, generated clients, mocks, tests, and documentation.
| File | Description |
|---|---|
packages/go/api/oas_validators_gen.go |
Generated consent validation. |
packages/go/api/oas_schemas_gen.go |
Generated consent types and errors. |
packages/go/api/oas_json_gen.go |
Generated consent JSON handling. |
packages/config/defaults/branding/minimal/login.liquid |
Adds scope choices to minimal design. |
packages/config/defaults/branding/centered/login.liquid |
Adds scope choices to centered design. |
packages/components/src/orchestrator/zitadel-login.ts |
Submits selections and controls Allow. |
packages/components/src/orchestrator/zitadel-login-auth-request.spec.ts |
Tests scope selection and submission. |
packages/components/src/orchestrator/templates/default.liquid |
Adds default consent controls. |
packages/components/src/orchestrator/mandatory-gates.ts |
Supplies choices to older templates. |
packages/components/src/orchestrator/mandatory-gates.spec.ts |
Tests template fallback behavior. |
packages/components/src/orchestrator/locales/it.ts |
Italian consent-control labels. |
packages/components/src/orchestrator/locales/en.ts |
English consent-control labels. |
packages/components/src/orchestrator/locales/de.ts |
German consent-control labels. |
packages/components/src/orchestrator/liquid.ts |
Registers consent-choice formatting. |
packages/components/src/orchestrator/liquid.spec.ts |
Tests localized choice formatting. |
packages/components/src/orchestrator/design-templates.spec.ts |
Tests choices across shipped designs. |
packages/components/src/orchestrator/consent-choices.ts |
Builds localized choice attributes. |
packages/components/src/atoms/zl-consent.ts |
Implements checkboxes, presets, and grant value. |
packages/components/src/atoms/zl-consent.spec.ts |
Tests interactive consent controls. |
packages/components/src/atoms/zl-consent.css |
Styles grouped scope choices. |
packages/components/src/atoms/index.ts |
Exports consent choice types. |
packages/components/src/atoms/event-contract.spec.ts |
Updates consent event expectations. |
packages/components/README.md |
Documents selection and localization. |
packages/api-mock/src/index.spec.ts |
Tests invalid consent grants. |
packages/api-mock/src/handlers.ts |
Rejects invalid mock grants. |
packages/api-mock/src/fixtures/login.ts |
Adds scope metadata to fixtures. |
packages/api-mock/src/consent-scope.ts |
Classifies scopes and validates selections. |
docs/design/branding/component-capability-map.md |
Documents interactive consent capabilities. |
docs/adrs/092-mcp-server.md |
Connects MCP authorization to selective consent. |
docs/adrs/082-oauth-and-oidc-server.md |
Records scope-selection decisions. |
apps/storybook/src/consent.stories.ts |
Demonstrates selectable consent scopes. |
apps/docs/content/docs/guides/customize-design.mdx |
Lists new consent styling parts. |
apps/console/src/features/sign-in/consent-texts.ts |
Supplies localized API scope labels. |
apps/console/src/features/sign-in/components/sign-in-screen.tsx |
Passes scope labels into login. |
apps/api/internal/storage/stmttest/auth_request_test.go |
Tests persisted scope narrowing. |
apps/api/internal/storage/dialect/sqlite/auth_request.go |
Stores granted scopes with codes. |
apps/api/internal/storage/dialect/spanner/auth_request.go |
Stores granted scopes with codes. |
apps/api/internal/storage/dialect/postgres/auth_request.go |
Stores granted scopes with codes. |
apps/api/internal/service/statement.go |
Documents scope persistence contract. |
apps/api/internal/service/flow_auth_request.go |
Passes selections to code issuance. |
apps/api/internal/service/flow_auth_request_test.go |
Tests grant forwarding. |
apps/api/internal/service/auth_request.go |
Revalidates grants before code issuance. |
apps/api/internal/service/auth_request_test.go |
Tests narrowed code issuance. |
apps/api/internal/flowengine/state.go |
Tracks consented scopes. |
apps/api/internal/flowengine/auth_request.go |
Builds choices and validates submissions. |
apps/api/internal/flowengine/auth_request_test.go |
Tests consent defaults and refusals. |
apps/api/internal/domain/flow_errors.go |
Defines invalid-consent error. |
apps/api/internal/domain/consent_scope.go |
Defines classification and grant rules. |
apps/api/internal/domain/consent_scope_test.go |
Tests classification and grant rules. |
apps/api/internal/api/scopes_test.go |
Checks scope naming and translations. |
apps/api/internal/api/integration_test/oauth_token_test.go |
Adapts code issuance calls. |
apps/api/internal/api/integration_test/oauth_code_test.go |
Adapts code redemption setup. |
apps/api/internal/api/integration_test/application_release_test.go |
Adapts application authorization setup. |
apps/api/internal/api/integration_test/access_token_test.go |
Tests narrowed token permissions. |
apps/api/internal/api/generated/oas_validators_gen.go |
Generated server consent validation. |
apps/api/internal/api/generated/oas_schemas_gen.go |
Generated server consent types. |
apps/api/internal/api/generated/oas_json_gen.go |
Generated server JSON handling. |
apps/api/internal/api/flow.go |
Maps consent metadata and errors. |
apps/api/api/openapi/endpoints/flows/submit/submitFlowStep-error-response.yaml |
Adds consent error response variant. |
apps/api/api/openapi/endpoints/flows/submit/methods.yaml |
Documents invalid-grant responses. |
apps/api/api/openapi/endpoints/flows/session/getFlowStep-error-response.yaml |
Updates flow error catalog. |
apps/api/api/openapi/components/schemas/errors/flow-consent_scopes_invalid.yaml |
Generated consent error schema. |
apps/api/api/openapi/components/flows/flow-submit-request.yaml |
Documents submitted scope selections. |
apps/api/api/openapi/components/flows/flow-step.yaml |
Defines scope metadata and consent contract. |
apps/api/api/openapi/components/examples/errors/flow-consent_scopes_invalid.yaml |
Generated consent error example. |
apps/api/api/openapi/bundled/openapi.json |
Regenerated API contract bundle. |
.changeset/oauth-sign-in-consent.md |
Updates customer-facing release notes. |
Review effort: Balanced
… three tools A review found the ADR's claim wrong that a client secret a tool returns is ended by rotating it: only a retry with the request's Idempotency-Key replaces a secret, and a tool sends no header. The ADR now says what ends each credential, the operator's reference no longer says such an operation is never a tool, and the amendment no longer names a guard that only #3543 adds. createInvitation and createProjectClaim are now called through their tools against the real API. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Review findings on the consent scope choice: - Allow needs a ticked API scope only when the step offers one: a request for offline_access alone, or for nothing, can be allowed again. - Every copy of the choice a template renders shows one grant, and allow follows a choice the template left unnamed. - A request another flow answered is refused as one (flow.auth_request_invalid, auth code not issued), not as a grant outside the scopes that flow narrowed it to. - The API mock refuses an allow without fields.scopes when nothing preselected reaches an API, as the engine does, and its conformance suite covers flow.consent_scopes_invalid. - The narrowing test asks for team.write, which createTeam needs, and shows the request granted as asked creating the team. New HTTP tests submit fields.scopes, redeem the code, and get no refresh token for an unticked offline_access; a grant nobody asked for is refused. - A test holds that scopes named .read reach only operations that read and handle no secret. - <zl-consent> gets its browser spec: the submitted grant, the keyboard on checkboxes and presets, form.reset() and a disabled fieldset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmRq5Pvdwoc568KP9Go
The consent choice starts closed: one line of what is granted ("Read only ·
Stay connected") and a Change button that opens the checkboxes, so Allow and
Deny follow it in the keyboard order however many scopes are asked for.
The login component now puts the server's choices into every consent summary
a template renders, so a template words and lays out the choice but never
decides what is offered or what starts ticked.
When the request asks for an API scope, an accept without `fields.scopes` is
refused with `flow.consent_scopes_invalid`, like an empty one: a screen that
offered no choice grants nothing the person never saw. A request for no API
scope still grants `offline_access`. The API mock refuses the same.
ADR 082's amendment, the components README, the parts table, the capability
map, the changeset and the consent story follow.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmRq5Pvdwoc568KP9Go
main's #3545 serves the flow tests from the shared Flow API mock, whose submits carry the session token and whose browser specs mount through the mock fixture. The consent tests here keep their grants and now send both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmRq5Pvdwoc568KP9Go
While no API scope is ticked, the consent choice says why allow waits
("Tick at least one permission to allow, or deny."). That line and what is
granted are live regions that describe the Change button, so a tick that
changes them is announced. Enter pressed while allow waits opens the choice
at its first scope instead of doing nothing.
A grant the server refuses (`flow.consent_scopes_invalid`) keeps the consent
step, with a translated reason as its error, instead of replacing the page
with the server's message.
The engine honours a named choice when the client became first-party while
the step was open; only an accept that names nothing keeps the request's
scopes. The API mock refuses an action the consent step lacks with
`flow.invalid_action`, as the engine does, and the browser spec again asserts
that the Enter leaned on after the password sends no accept.
The spec describes scope groups and access by name only; an API's own
declarations land with `apis`, as ADR 082's amendment now says, along with
the empty grant's token response.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmRq5Pvdwoc568KP9Go
Closed, the consent choice now names the groups its grant reaches, a line per access under what is granted: "View: Users, Audit log", "Edit: Teams", "Delete: Users". Every group is listed, however many, so the person sees which kinds of data they allow without opening the choice, and the lines always match what Allow sends. They are a live region and describe the Change button, so a screen reader hears them before Allow. A scope outside any group is named by its own line. Reads, sensitive ones included, stay ticked to start, now that the closed choice names them. ADR 082's amendment, the components README, the parts table, the capability map and the changeset say so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmRq5Pvdwoc568KP9Go
…cope Picks up what landed on main in between: #3541, #3539, #3543 and #3542. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
Picks up what landed on main in between: #3538, #3541, #3539 and #3543. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
The user decided that the CLI, the API and MCP matter more than the Console for creating a PAT. So a person's OAuth token may create one with a scope the consent step never preselects, holding no scope that token lacks; a PAT still never creates one, and the creating client is recorded. Scope choice on consent is on main (#3543), which the first draft missed. A PAT is now an opaque 256-bit secret stored as its SHA-256, with its record id and a checksum in the token, so it depends on no key and a copy of the table holds nothing usable. The 90-day limit is to become a policy later. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0137eGmS8uCXd1d5jCxWaiSf

Context
Connecting an MCP client (Claude, ChatGPT, VS Code) to the platform's
/api/v1/mcpgave it a token with all 28 person scopes,user.deleteanddeployment.writeincluded. The endpoint's challenge names noscope, so the client asks for everything inscopes_supported; the issuer grants what was asked; and the consent step had only Allow and Deny.Summary
The person now chooses which of the requested scopes to grant, and only reading starts ticked.
Server and API contract
scopes[]gaingroup,access(read|change|delete|offline) andselected.accessandgroupfollow the naming rule<group>.<verb>:.readreads,.deletedeletes, any other verb changes. An API's own declaration of them is to win once applications declareapis.acceptnames the grant infields.scopes. It must be a subset of the request and, when the request asks for any API scope, hold one; otherwise400 flow.consent_scopes_invalidand the step stays. Granting nothing isdeny.acceptwithoutfields.scopesis refused the same way, so a screen that offered no choice grants nothing the person never saw. A request for no API scope still grantsoffline_access.IssueCodechecks it again and writes the narrowed scopes in the sameUPDATEthat stores the code (all three dialects). The token response'sscopenames the grant (a grant of no scope at all has none, and no refresh token); a refresh asking for more stays refused.<zitadel-login><zl-consent>offers the scopes as native checkboxes grouped bygroup, with "Read only" and "Everything requested" presets and "Stay connected" (offline_access) as its own toggle, ticked. Its value is the granted scopes; Allow stays disabled until an API scope is ticked.flow.consent_scopes_invalid) keeps the consent step with a translated reason, rather than replacing the page with the server's message.locales, asconsent.scope.<scope>andconsent.group.<group>, like every other login text.Console: its sign-in passes the Zitadel API's scope texts (28 scopes, 17 groups, en/de/it) through
locales. A server test fails a person scope without a line there in all three languages.API mock: classifies scopes like the server and refuses the grants the engine refuses, an unnamed accept of an API scope included. An action the consent step lacks is
400 flow.invalid_action, as on the server.Validation
go test ./internal/...(apps/api)go test -tags sqlite_integrationon./internal/api/integration_test/ ./internal/api/integration_test/helpers/ ./internal/bootstrap/platform/ ./internal/storage/dialect/sqlite/ ./internal/storage/stmttest/, including a new platform-API case: a token narrowed touser.readreads users and is refusedcreateTeam.turbo run generate --filter=@zitadel/server, thenturbo run check-generate --filter=@zitadel/serverturbo run lint --filter=@zitadel/server: green exceptformat, which flagsinternal/flowengine/sso_test.go. This PR doesn't touch that file, and it is unchanged frommain.turbo run lint typecheck --filter=@zitadel/components --filter=@zitadel/api-mock --filter=@zitadel/console --filter=@zitadel/storybookvitest --project unit(1099) and--project browser(264) inpackages/components,vitestinpackages/api-mock(551),turbo run test --filter=@zitadel/console(1190),turbo run test --filter=@zitadel/storybookRelease notes / changeset
.changeset/oauth-sign-in-consent.md. It is unreleased, so this PR edits it rather than adding one (.changeset/README.md). It lists@zitadel/server,@zitadel/api,@zitadel/componentsand@zitadel/config, and now says the person chooses the scopes and that an app words its API's scopes inlocales.Notes
main, mergemainin and runturbo run generate --filter=@zitadel/server..readsuffix.offline_accessis its own toggle, preselected.accessis optional, with the naming rule as fallback.TestReadScopesReachOnlyReadsfails a read scope that reaches an operation taking or returning a secret, so such an operation's scope never starts ticked.apisin the application document, with optionalaccessandgroupper scope) land separately. The ADR 082 amendment describes them; until then the server classifies every scope by its name, and the spec says only that.project.readalso reads invitations, so the console's "View projects" could read "View projects and their invitations".https://claude.ai/code/session_0137eGmRq5Pvdwoc568KP9Go
Generated by Claude Code