Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/docs/tests/pages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ test("llms-full.txt carries every page but the API operations", async ({ request
operations.filter((page) => full.includes(`(${origin}${page.url})`)).map((page) => page.url),
"API operations in llms-full.txt",
).toEqual([]);
expect(full.length).toBeLessThan(650_000);
expect(full.length).toBeLessThan(750_000);
});

test("scripts and styles load from /docs/_next/", async ({ request }) => {
Expand Down
85 changes: 58 additions & 27 deletions docs/adrs/033-internal-permission-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
> **Status:** Proposed
> **Date:** 2026-07-09
> **Context:** Authorization for Zitadel-owned internal resources (projects, teams, users, apps, flows, policies) and agent delegation. Builds on [ADR 032](032-permission-catalogs.md).
>
> **Amended 2026-11-25** (§3, §5): how the management API resolves and records
> a call made for a user. The rule for the tokens themselves, that each names
> who acts and none hides its actor, is
> [ADR 082 §7](082-oauth-and-oidc-server.md#7-tokens)'s and holds for every
> project. Here: consent is its own record, not an assignment; an acting
> principal never gets a copy of the user's permissions; a delegated event
> records the actor, the user, the grantor and the `delegation_id`. An agent
> is an application, and its client is the principal.

## Introduction

Expand Down Expand Up @@ -47,7 +56,7 @@ Terms specific to internal/system-catalog authorization, in addition to
|---|---|
| **System catalog** | The catalog of Zitadel-owned permissions and optional bundles for internal API resources; replaces legacy level-specific role semantics. See [ADR 032 §1](032-permission-catalogs.md#1-one-model-two-catalogs). |
| **Credential class** | The kind of principal presenting a request (user token, `sk_proj_`, `sk_team_`, origin-bound browser nonce), which constrains which permissions/scopes are even reachable regardless of grants. |
| **Agent delegation** | A scoped, explicit, auditable grant of authority from a human or service principal to an agent, distinct from the agent inheriting the grantor's full permission set. |
| **Delegation** | Authority to act for a user: the user's consent to a client, a token exchange, or an operator's act-as that the user did not grant. Scoped, explicit and audited under one `delegation_id`, distinct from the acting principal inheriting the user's full permission set (§3). |

## Context

Expand Down Expand Up @@ -77,8 +86,9 @@ Two related issue areas constrain the decision:

- Tenant isolation and data residency need project/tenant boundaries that
can be enforced before resource data is fetched.
- Agent identity needs first-class principals and scoped delegations, not
broad inherited user authority.
- Agents need scoped delegations, not broad inherited user authority. An
agent is an application, and the client it acts through is the principal
([identity model](../design/api/identity-model.md#applications)).

Cross-project human identity (agencies, consultants, platform staff, and
operators) is a related but distinct issue area, tracked by
Expand Down Expand Up @@ -140,15 +150,29 @@ access is out of scope here (see Introduction, [#333](https://github.com/zitadel
whatever grant model that future ADR defines must fit this same
storage/residency invariant, not bypass it.

### 3. Agent delegation

Agent delegations are stored as assignments with an explicit grantor,
delegation id, expiry/revocation state, and scope (the general storage
shape from [ADR 032 §3](032-permission-catalogs.md#3-canonical-relational-storage)).
An agent never receives permissions by copying all permissions from its
owner. The resolver must be able to explain which delegation authorized or
denied an agent action, so that both audit review and the agent itself can
see exactly why an action succeeded or failed.
### 3. Delegation

**Amended 2026-11-25.** What a delegation is, and what a token issued under
one carries, is decided once for every project in
[ADR 082 §7](082-oauth-and-oidc-server.md#7-tokens): the token names who acts
in `act`, the delegation has one `delegation_id`, and there is no
impersonation. This section says what the management API does with such a
call. What a customer's API does with one is
[ADR 034](034-external-permission-management.md#open-questions)'s.

Consent is a record of its own per user, client and protected API, holding a
set of scopes ([ADR 082 §8](082-oauth-and-oidc-server.md#8-consent)). It is
not an `authz_assignments` row: that table's foreign key to a catalog
relation, its principal types, which have no client, and its lack of an API
column cannot hold it. Assignment rows reference a `delegation_id` only for
grants on Zitadel's own API; those are stored with an explicit grantor,
expiry/revocation state, and scope (the general storage shape from
[ADR 032 §3](032-permission-catalogs.md#3-canonical-relational-storage)).

An acting principal never receives permissions by copying all permissions
from the user it acts for. The resolver must be able to explain which
delegation authorized or denied an action, so that both audit review and the
acting principal can see exactly why an action succeeded or failed.

### 4. Resolver and list filtering for internal resources

Expand Down Expand Up @@ -201,20 +225,27 @@ the same authorization semantics.

### 5. Audit trail and grant provenance

Every action performed under an explicit grant or agent delegation records
the grant context in the event actor metadata. For example, an agent acting
under a delegation:
Every action performed under an explicit grant or a delegation records the
grant context in the event actor metadata. A delegated event records `actor`,
the acting principal (a client or an operator); `user_id`, the user acted
for; `grantor`, who authorized it; `delegation_id`; and `delegation_type`.
For example, a client acting for a user under a delegation:

```
actor: agent:report-bot
delegation_id: delegation-123
grantor: user:alice
action: project.export.create
target: project:42
actor: client:report-bot
user_id: user:alice
grantor: user:alice
delegation_id: delegation-123
delegation_type: delegated
action: project.export.create
target: project:42
```

This makes delegated agent actions visible in the resource owner's audit
log. There is no hidden access path: the grant check and the audit record
The event contract still lists `agent` as an actor type until the rename to
`client` lands ([identity model](../design/api/identity-model.md#what-changes)).

This makes delegated actions visible in the resource owner's audit log.
There is no hidden access path: the grant check and the audit record
are the same code path. (The equivalent shape for staff/support grants —
issuer, human-readable `reason`, role tier, and a break-glass escape hatch
for when normal grant issuance is unavailable — is defined by
Expand Down Expand Up @@ -266,14 +297,14 @@ scoped SQL query against data we already own.
`app.read`, `app.write`, `app.delete` — and extend to all Zitadel resource
types. Canonical names live in
[`docs/design/api/system-permission-catalog.md`](../design/api/system-permission-catalog.md).
2. Design relational migrations for `resource_scope_index` and agent
delegation columns on `authz_assignments` (D2 — not sibling delegation
tables). Wave 0 DDL spike and locked decisions:
2. Design relational migrations for `resource_scope_index` and the
delegation columns on `authz_assignments` for grants on Zitadel's own API
(D2 — not sibling delegation tables; consent is its own record, §3). Wave 0 DDL spike and locked decisions:
[`docs/design/api/permission-storage.md`](../design/api/permission-storage.md)
(implementation tracked by [issue #422](https://github.com/zitadel/nextgen/issues/422)).
3. Update OpenAPI security declarations to use the final permission names.
4. Define agent delegation schema, audit record shape, and denial
explanation fields.
4. Define the delegation schema, audit record shape, and denial explanation
fields.
5. Staff/support access, cross-project human identity, and the break-glass
escape hatch are tracked by [issue #333](https://github.com/zitadel/nextgen/issues/333)
and intentionally out of scope here. Cross-project principals are
Expand Down
17 changes: 17 additions & 0 deletions docs/adrs/034-external-permission-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,20 @@ they apply to both catalogs, not just this one.
external permissions.
2. Design relational migrations for app-group catalog tables and app
grants.

## Open questions

Added 2026-11-25. This ADR binds users and teams to apps and predates the
rule that a token issued for a user names who acts
([ADR 082 §7](082-oauth-and-oidc-server.md#7-tokens)). It does not yet say
what that rule means for a customer's app:

1. Whether a client can hold an app grant, so that an agent acting as itself
gets permission claims, or app grants stay for users and teams.
2. Which permission claims a token carries when a client acts for a user: the
user's app grants as they are, or those grants narrowed by the scopes the
user consented to
([ADR 082 §8](082-oauth-and-oidc-server.md#8-consent)). On Zitadel's own
API an acting principal never gets a copy of the user's permissions
([ADR 033 §3](033-internal-permission-management.md#3-delegation));
whether a customer's app gets the same guarantee is not decided.
30 changes: 30 additions & 0 deletions docs/adrs/036-api-credential-planes.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,33 @@ A deployment to `primary` freezes the project's primary origins, and a rollback
restores the ones it names. A primary origin serves the newest primary
deployment only when that deployment names it and the project still lists it.
So an added origin waits for a deploy, and removing one takes effect at once.

## Amendment (2026-11-25): the management API accepts platform bearers

The management API accepts access tokens issued by the platform project's
issuer whose audience is the management API. It checks the session on every
call and admits exactly the operations a console session may call. A session
cookie is accepted only from a browser on the issuer's own origin, and every
other caller presents a bearer. The server verifies the issuer and the
signing project exactly, so a customer project's token cannot pass as a
platform token. This is the user bearer
[ADR 053 §5](053-cross-project-principals.md#5-first-party-human-sessions-may-call-the-operator-plane)
expects, with the same principal and grant semantics as the console's cookie.

| Caller | Credential |
|---|---|
| The console, on the issuer's origin | Its session cookie |
| The login widget and SDK proxy in a customer's app | The end user's session cookie, with the publishable key |
| The CLI | The platform token it gets from `zitadel login` |
| A remote MCP client | A bearer: a personal access token first, an OAuth token once consent and client registration ship ([ADR 082](082-oauth-and-oidc-server.md#recommended-sequence)) |
| CI and customer backends | The project secret today; workload identity federation is planned, GitHub Actions first, and service applications later |

Personal access tokens are added as a bridge, on four conditions:

- each has a required expiry;
- an event's actor is the token's owner;
- each can be revoked;
- a personal access token is never a client's identity.

This brings in operator PATs, which the operator row and
[Out of scope](#out-of-scope) put later, as that bridge.
10 changes: 10 additions & 0 deletions docs/adrs/037-token-lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
> **Status:** Accepted
> **Date:** 2026-06-30
> **Context:** Evolution of session security
>
> **Amended 2026-11-25** (Personal Access Tokens): personal access tokens are
> added as a bridge to the management API, on the conditions of
> [ADR 036](036-api-credential-planes.md#amendment-2026-11-25-the-management-api-accepts-platform-bearers).

## Context

Expand Down Expand Up @@ -129,3 +133,9 @@ possible right now.

PATs are out of scope for now as well. They do not provide any extra value yet
in the MVP.

**Amended 2026-11-25:** PATs are added as a bridge to the management API: a
remote MCP client presents one until OAuth consent and client registration
ship. A PAT has a required expiry, can be revoked, makes its
owner the actor of the events it causes, and is never a client's identity
([ADR 036](036-api-credential-planes.md#amendment-2026-11-25-the-management-api-accepts-platform-bearers)).
50 changes: 45 additions & 5 deletions docs/adrs/082-oauth-and-oidc-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@
> only when it sent Basic credentials. The code names the deployment that
> served its request, so a declared client authenticates against that
> deployment's variable (zitadel/nextgen#2796).
>
> **Amended 2026-11-25** (§7, §8, §11, open questions 7 and 8): every call
> made for a user names who acts, in every project's tokens: a token issued
> for a user on behalf of another principal carries `act`, and no token hides
> its actor (§7). A consent is a delegation: one record per user, client and
> API, holding a set of scopes, with a `delegation_id` that its tokens and
> their events share. Token exchange is delegation, never impersonation.

## TL;DR

Expand Down Expand Up @@ -408,11 +415,35 @@ to revoke the tokens issued for a code that is used twice, when possible.
ADR 037 stores nothing for access tokens, so there is nothing to revoke until
refresh tokens ship.

#### A token issued for a user names who acts

**Amended 2026-11-25.** Every call made for a user names who acts: a token
issued for a user on behalf of another principal carries `act`, and Zitadel
issues no token that hides its actor. This holds for every project's tokens,
a customer's and the platform project's alike.

A delegation is a user's consent to a client (§8), a token exchange (§11), or
an operator's act-as that the user did not grant. It has one `delegation_id`,
which the consent record, the tokens and every event share.

There is no impersonation. A support or admin act-as is a delegation the user
did not grant, named and recorded as one.

What an API does with such a token is its own. The management API resolves
and records it as
[ADR 033 §3](033-internal-permission-management.md#3-delegation) and
[§5](033-internal-permission-management.md#5-audit-trail-and-grant-provenance)
say. A customer's API reads it from the token; which permission claims that
token holds is open in
[ADR 034](034-external-permission-management.md#open-questions).

### 8. Consent

A consent records that a user let a client use some scopes. It is kept per
user, client and scope, and is called a consent because ADR 032 uses *grant*
for permissions. The flow engine inserts the consent step (ADR 081 §11) when
user, client and API, as one record holding a set of scopes, and is called a
consent because ADR 032 uses *grant* for permissions. A consent is a
delegation (§7): it carries a `delegation_id`, which the tokens issued under
it and their events share. The flow engine inserts the consent step (ADR 081 §11) when
a third-party client asks for scopes the user has not consented to, and
whenever a request says `prompt=consent`, and on every request for an
application whose document says so (§3). The scope descriptions on the
Expand Down Expand Up @@ -471,9 +502,11 @@ enterprise-managed authorization builds on token exchange and comes with it

### 11. Later

- Token exchange (RFC 8693), first, since delegation, impersonation and
workload identity federation ride on it, and MCP's enterprise-managed
authorization with them (§10).
- Token exchange (RFC 8693), first, since delegation and workload identity
federation ride on it, and MCP's enterprise-managed authorization with them
(§10). Token exchange is delegation, never impersonation: a token it issues
for a user names the acting client in `act`, and Zitadel issues none that
hides its actor (§7).
- Device authorization (RFC 8628) for CLIs and TVs.
- Back-channel logout for third-party clients (first-party ones share the
session, ADR 081 §12).
Expand Down Expand Up @@ -598,6 +631,13 @@ protocol spans the server, the SDK proxy and the widget.
`<zitadel-session>`, and its name.
6. How a registered application moves into the release, since the release
build refuses a file that takes its slug (§3).
7. Whether a first-hop token, which a client obtains itself with the
authorization code grant, carries `act` in addition to `client_id`, or
`act` appears only when a different principal presents the user, through
token exchange or an operator's act-as (§7).
8. Whether an access token carries the `delegation_id` as a claim, and under
which name, so that an API outside Zitadel can record the delegation a
call was made under, or only Zitadel's own records hold it (§7).

## Rejected alternatives

Expand Down
Loading
Loading