Skip to content

feat(api): let a person create personal access tokens for agents and CI - #3563

Merged
fforootd merged 22 commits into
mainfrom
claude/personal-access-tokens-api
Dec 2, 2026
Merged

fforootd merged 22 commits into
mainfrom
claude/personal-access-tokens-api

Conversation

@fforootd

@fforootd fforootd commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Context

An agent with no person at the keyboard (a CI job, a scheduled task, a coding agent in a cloud container) could reach the management API and the MCP endpoint only with a project secret, which stands for every scope, cannot be narrowed and names no person in events.

Summary

  • New operations under /users/me/personal_access_tokens: createMyPersonalAccessToken, listMyPersonalAccessTokens, revokeMyPersonalAccessToken.
  • Off by default. personal_access_tokens.enabled (NEXTGEN_PERSONAL_ACCESS_TOKENS_ENABLED) turns them on. Off, the three operations answer 501 and a zpat_ bearer is refused. The cloud launcher does not turn it on.
  • Token format: zpat_<id>_<secret><checksum>. The secret is 256 random bits; the tokens record keeps its SHA-256 and compares in constant time. A bad checksum is refused before any read.
  • Use: the API and the MCP endpoint take a PAT through the same gate as a person's access token (admitPersonToken). The owner is the principal, and the PAT's scopes cap what the owner holds on each call. An expired or revoked PAT, or one whose owner is not active, answers 401.
  • Creation takes a Console session, or an access token that carries personal_access_token.create. Consent never preselects that scope, and a first-party client is asked for it too. The PAT holds no scope that token lacks and records the token's client. A PAT never creates a PAT. A person holds at most 50 that have not expired.
  • On the MCP endpoint the create tool asks the person first where the client can ask, and is sent where it cannot, as ADR 094 §5 decides for a marked call with a scope of its own. A new spec marker, x-zitadel-asks, carries that mode for this one operation; TestCatalogMarksWhatIsAskedWhereTheClientCan gates which operations carry it. A project secret is shown none of the three tools.
  • Events of a PAT's calls: the actor is the owner, actor_type human, token_id the PAT, delegation_type pat_shared. auth.token.issued gains type and expires_at.
  • Migration in three dialects: tokens gains nullable name, secret_hash and client_id.
  • Also: consent texts for the three scopes (en, de, it), a docs guide (guides/personal-access-tokens.mdx), rows in the events catalog, the setting in nextgen.example.yaml and the configuration guide, and a pointer from the identity model draft.

Validation

Run by the session that wrote the change, in its cloud container, on its working branch (which also held the CLI's commits):

  • PostgreSQL 16: the dialect, migration and stmttest suites and every API integration test pass.
  • Spanner emulator: the dialect and migration suites and the PAT, MCP and client-document integration tests pass. Two stmttest search tests fail the same way on a clean main under the emulator, and three more time out only under full-suite load and pass alone, as on main.
  • The SQLite lane and all Go unit tests pass. turbo run generate, check-generate and openapi for the server, and pnpm run check-openapi-rules, pass.
  • CI's full-pr was green on that working branch's last head (feat(api): let a person create personal access tokens for agents and CI #3556 at 609f1eef1), whose tree the stack of this pull request, feat(api): serve the CLI's client document on the platform issuer #3558 and the CLI's reproduces exactly. The Spanner lane (spanner.yml, Spanner Omni) is not one of a pull request's checks and has not run.
  • What the tests show, each failing without the change: a PAT is created from a session and from a token holding the create scope; creation is refused without that scope, naming it; a PAT is capped to the creating token's scopes; a PAT never creates one; it works on the API inside its scopes and gets 403 naming the scope outside them; it ends on revoke, on expiry, when the owner loses the role and when the owner is deactivated; another person's PAT answers 404; the stored row and the events hold no secret; a forged or mistyped token is refused; through MCP the tools are cut to the PAT's scopes, and an agent creates its own PAT with an endpoint token after answering the endpoint's question.

Run again when opening this draft, on the nine commits cherry-picked onto the ADR branch:

  • go build ./... and go vet of internal/api, internal/mcp, internal/service
  • go test ./internal/api/ ./internal/domain/ ./internal/service/ ./internal/mcp/ ./internal/oauth/ and go test ./cmd/server/ -run 'PersonalAccessToken|Config|OAuth'
  • go test -tags sqlite_integration ./internal/api/integration_test/ -run 'PersonalAccessToken|MCP' and the token statements on SQLite
  • node scripts/check-pr-title.mjs --title "…"
  • After CI's first run on this branch alone: the CLI's coverage test holds that every operation the API client offers is called by a command or explained, and the commit that satisfied it lives in the CLI's pull request. A commit added here by the coordinating session explains the three operations as ones the CLI does not call yet (api-coverage.test.ts passes, 9 tests; Biome clean on the file); feat: sign in from the CLI, and create personal access tokens with it #3564 takes the explanation out again.

Release notes / changeset

  • Changeset: .changeset/personal-access-tokens.md (@zitadel/server and @zitadel/api, minor).

Notes

  • Security review. An independent review of the first implementation commit ran its tests and a fuzz of the parser and found no bug in parsing, verification, ownership or storage. It raised four points about where the credential sits; three are built here and one is open:
    • A PAT leaves the audience of the token that created it, and with it the MCP endpoint's question before a destructive call. ADR 095 states the risk, and the endpoint now asks before creating one.
    • PATs were on wherever a platform project is resolved. They now have a setting of their own, off by default.
    • A first-party client would have got the create scope with no consent step. It is now always asked.
    • Open: a Console session can create a PAT with every scope and no fresh sign-in, and a password change does not end it. ADR 095 lists the options; none is built. The writing session recommends ending a person's PATs on a password change or reset and asking for a recent sign-in before a session creates one. The guide tells owners to list and revoke after recovering an account.
  • Decisions taken for review: a fixed 90 days (a policy later); a PAT outlives the grant of the client that created it; the cap of 50; PATs default to off.
  • MCP tool list. Three tools in the users tool set, which makes 91 on a plain URL under the ceiling of 100, and 52 tools, 68,271 bytes, on the list a default consent yields, under its budget of 80,000 (feat(api): let an MCP client choose tool sets, and reads only, by its URL #3555's three checks; the raise of the one budget this change first made is gone).
  • A person's own operations. The spec marks the three operations x-zitadel-self, as it marks a person's own reads (feat(api): let a person's token read who they are and which projects they can act on #3559): the CLI, which holds a project secret, refuses them with its own reason, and the docs' samples show a token issued for the person. The API passes a secret over on them before it is looked at, so the request is answered as one that sent no bearer. In the contract tests they stay a class of their own, since they name no project.
  • Migration numbers. Postgres 000064, Spanner 000068 and SQLite 000051, behind refactor(api): add the session type to the permission catalog #3551's. The open webhooks drafts refactor(api): add storage for a project's webhooks #2987 and feat(api): deliver a project's events to its webhooks, signed #2991 use numbers below these; whoever merges later renumbers.
  • Follow-ups for whichever merges second:
  • Not built: a Console page, a purge of expired rows, an RFC 7009 revocation endpoint.
  • Written in the session https://claude.ai/code/session_0137eGmS8uCXd1d5jCxWaiSf; the commits were cherry-picked onto the ADR branch and the draft opened by the coordinating session below.

https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U


Generated by Claude Code

claude added 15 commits December 2, 2026 07:05
…platform

ADR 095 is the record ADR 094 §5 waits for before a PAT is admitted. A PAT
belongs to a person homed in the platform project and acts as them, capped
by its scopes, on the operations a person's token reaches. It expires within
90 days, is created only from a Console session, and is listed and revoked
by its owner.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmS8uCXd1d5jCxWaiSf
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
Creating a PAT is a marked call with a scope of its own, so ADR 094 §5's
rule fits it: the scope is the gate, and the MCP endpoint asks where the
client can answer once it asks about marked calls at all.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmS8uCXd1d5jCxWaiSf
(cherry picked from commit c757ba5)
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmS8uCXd1d5jCxWaiSf
(cherry picked from commit bef352c)
PATs are off until personal_access_tokens.enabled switches them on, since
they do open a bearer path a server without OAuth did not have, and §7 no
longer says otherwise. The create scope is never granted without the
consent step, and the MCP endpoint asks before a PAT is created where the
client can. A person holds at most 50 live PATs. The risks now name the
audience a PAT leaves and the Console session that outlives recovery,
with the options and a recommendation for the latter.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmS8uCXd1d5jCxWaiSf
(cherry picked from commit 93677b0)
A person homed in the platform project creates a PAT with
createMyPersonalAccessToken (POST /users/me/personal_access_tokens), lists
and revokes their own with listMyPersonalAccessTokens and
revokeMyPersonalAccessToken, from a Console session, an access token issued
for them, or (to list and revoke) a PAT (ADR 095).

A PAT reads zpat_<id>_<secret><checksum>: a 256-bit random secret whose
SHA-256 the tokens record keeps, found by the record id and compared in
constant time; a wrong checksum is refused before any read. The API and the
MCP endpoint take it on the operations an access token issued for a person
reaches, through the same gate: its owner is the principal, its scopes a
ceiling on the owner's grants at each call, and a refusal names the scope.
It expires within 90 days and stops while its owner is not active.

Creating one with an access token needs personal_access_token.create, which
consent never preselects; the PAT holds no scope that token lacks and records
its client. A PAT never creates one. Events of a PAT's calls name the owner
as a human actor, the PAT as token_id and pat_shared as delegation_type.

tokens gains name, secret_hash and client_id in the three dialects. The MCP
tool list budget is raised by the three tools' 3,700 bytes until the change
that makes room in it lands.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmS8uCXd1d5jCxWaiSf
(cherry picked from commit 442a041)
…client

A first-party client is asked no consent, so it would be granted
personal_access_token.create unasked, and with it a credential that
outlives its grant. The scope is now granted only on the consent step,
whoever the client is.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmS8uCXd1d5jCxWaiSf
(cherry picked from commit edec824)
…ault

PATs were served wherever the platform project is, outside oauth.enabled,
so a server that took no person's bearer before would take a PAT after.
personal_access_tokens.enabled (NEXTGEN_PERSONAL_ACCESS_TOKENS_ENABLED) now
switches them on, off by default as oauth.enabled is. Off, the three
operations answer not_implemented and a zpat_ bearer is refused as an
unknown one.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmS8uCXd1d5jCxWaiSf
(cherry picked from commit 55f1699)
…pired

A credential that is only ever added to is one nobody reviews. Creating a
51st live PAT is refused with tkn.pat_invalid until the person revokes one.
Expired rows stay until a purge, which is a follow-up, and are not counted.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmS8uCXd1d5jCxWaiSf
(cherry picked from commit 234fa22)
A PAT leaves the audience of the token that created it: a token issued for
the MCP endpoint creates one through the endpoint, and the PAT then
answers on the API directly, where the endpoint's questions do not reach.
createMyPersonalAccessToken is now marked x-zitadel-asks: the endpoint asks
the person where the client can ask them, and sends the call where it
cannot, its own scope, ticked on purpose, being the gate (ADR 094 §5). The
tool says so, at 84 bytes, which the list budget's raise now counts.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmS8uCXd1d5jCxWaiSf
(cherry picked from commit 3b94cf2)
The endpoint now asks before createMyPersonalAccessToken where the client
can ask, so the agent's client in the integration test answers as its
person would, and the test holds that the person was asked.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmS8uCXd1d5jCxWaiSf
(cherry picked from commit 6cc66fb)
A project secret's scopes cover the three operations on a person's own
PATs, so the MCP endpoint listed them as tools that could only be refused.
No secret is anyone's person: Covers now passes them over for a secret.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmS8uCXd1d5jCxWaiSf
(cherry picked from commit 4d64c49)
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmS8uCXd1d5jCxWaiSf
(cherry picked from commit 6108cd1)
A PAT is persisted only with its secret's hash, and the Postgres dialect's
own token test still created one without it, which the Postgres lane
refused.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmS8uCXd1d5jCxWaiSf
(cherry picked from commit 5c38672)
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmS8uCXd1d5jCxWaiSf

(the ADR part of commit 36bd497ba2, whose renames of CLI files belong to the CLI change)
@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 2, 2026 4:12pm UTC

Request Review

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

🦋 Changeset detected

Latest commit: 377ba57

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/cli Minor
@zitadel/components 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/testing 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

…not call yet

The CLI's coverage test holds that every operation the API client offers is
called by a command or explained. The three personal access token operations
are a person's own, and the CLI holds a project secret until it can sign a
person in, so they are explained here. The CLI's sign-in and its token
commands, which call them, are their own change on top of this one and take
the explanation out again.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
@fforootd
fforootd marked this pull request as ready for review December 2, 2026 14:08
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-12-02T14:16:01.685623Z 561767b Draft marked ready

Security findings

Advisory findings (1)

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Codex Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 561767b8a4

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

security:
- oauth2:
- personal_access_token.create
- sessionCookie: []

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛡️ Codex Security Review · Automatically triggered

P1 Badge Security: Require reauthentication before a session mints a PAT

Condition: personal access tokens are enabled and an attacker controls an active platform-user session. The new sessionCookie alternative mints a PAT without fresh authentication or step-up. The PAT is an independent record valid for up to 90 days; verification checks its row, expiry, scopes, grants, and active owner, while session revocation deletes only tokens carrying that session ID. Cookie theft or same-origin script execution can therefore create a bearer that survives sign-out/recovery and retains the victim's cross-project grants. Require recent reauthentication for issuance and invalidate PATs during account recovery.

Useful? React with 👍 / 👎.

Base automatically changed from claude/personal-access-tokens-adr to main December 2, 2026 14:47
…-api

main chose tool sets by URL (#3555): the catalog keeps this branch's asksWhereItCan beside main's tags, and the one budget on the tool list gives way to main's three checks.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
main holds this branch's base, ADR 095, as one squash commit (#3548). Its tree is the base's final head merged with the main before it, which this branch already holds, so the squash is recorded as merged and nothing changes.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
main gained a person's own reads (#3559), the client secret's rotation (#3561), the session type (#3551) and the CLI's client document (#3558). The personal access token migrations move behind the session type's (Postgres 64, Spanner 68, SQLite 51). A secret is refused on a person's own reads and on their personal access tokens alike, and the server's code is generated again from the merged spec. The tool-set tests expect the three token tools in the users set.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
The spec marks createMyPersonalAccessToken, listMyPersonalAccessTokens and revokeMyPersonalAccessToken x-zitadel-self, as it marks a person's own reads: the CLI, which holds a project secret, refuses them with its own reason, and the docs show a token issued for the person in their samples. The API passes a secret over on them before it is looked at, as on a person's own read, so the request is answered as one that sent no bearer. They stay a class of their own in the contract tests, since they name no project.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
main gained a person's own sessions (#3560). The server's code is generated again from the merged spec, the tool-set tests expect both changes' tools in the users set, and ADR 092's measured figures count the three token tools: 91 on a plain URL, and 52 tools, 68,271 bytes, on the list a default consent yields.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
@fforootd
fforootd enabled auto-merge December 2, 2026 16:09
@fforootd
fforootd added this pull request to the merge queue Dec 2, 2026
Copilot AI balanced review requested due to automatic review settings December 2, 2026 16:29
Merged via the queue into main with commit 348f144 Dec 2, 2026
19 checks passed
@fforootd
fforootd deleted the claude/personal-access-tokens-api branch December 2, 2026 16:35

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

The live-PAT limit can be bypassed by concurrent creates or the newest-500 counting window, and declared API errors lose operation-specific variants in generated clients.

3 open issues
What changed in this PR

Implements ADR 095 personal access tokens, giving agents and CI scoped access as a person rather than through a project secret.

Changes:

  • Adds token creation, listing, revocation and authentication, disabled by default.
  • Integrates consent, MCP confirmation, audit events and storage across three database dialects.
  • Updates API contracts, generated Go code, tests and documentation.
File Description
packages/​go/​api/​oas_validators_gen.go Generates PAT validation.
packages/​go/​api/​oas_security_gen.go Adds PAT authentication mappings.
packages/​go/​api/​oas_request_encoders_gen.go Encodes creation requests.
packages/​go/​api/​oas_parameters_gen.go Adds list and revoke parameters.
packages/​go/​api/​oas_operations_gen.go Adds operation names.
packages/​go/​api/​oas_interfaces_gen.go Adds response interfaces.
packages/​go/​api/​oas_cfg_gen.go Adds token-ID validation pattern.
docs/​quick-start/​configuration.md Documents the feature switch.
docs/​operations/​nextgen.example.yaml Shows disabled-by-default configuration.
docs/​design/​api/​identity-model.md Clarifies the implemented identity model.
docs/​design/​api/​events-catalog.md Documents PAT audit events.
docs/​adrs/​092-mcp-server.md Updates tool counts and budgets.
apps/​docs/​content/​docs/​guides/​personal-access-tokens.mdx Adds the PAT usage guide.
apps/​docs/​content/​docs/​guides/​meta.json Links the new guide.
apps/​console/​src/​features/​sign-in/​consent-texts.ts Adds translated consent labels.
apps/​cli/​tests/​unit/​cli/​commands/​api-coverage.test.ts Records deferred CLI operation coverage.
apps/​api/​internal/​storage/​stmttest/​token_test.go Tests PAT persistence and ownership.
apps/​api/​internal/​storage/​stmttest/​schema_nullability_test.go Checks nullable token names.
apps/​api/​internal/​storage/​stmttest/​cursor_battle_test.go Updates PAT pagination fixtures.
apps/​api/​internal/​storage/​dialect/​sqlite/​token.go Persists PAT fields in SQLite.
apps/​api/​internal/​storage/​dialect/​sqlite/​migration/​sql/​000051_personal_access_tokens.sql Adds SQLite PAT columns.
apps/​api/​internal/​storage/​dialect/​spanner/​token.go Persists PAT fields in Spanner.
apps/​api/​internal/​storage/​dialect/​spanner/​migration/​sql/​000068_personal_access_tokens.sql Adds Spanner PAT columns.
apps/​api/​internal/​storage/​dialect/​postgres/​token.go Persists PAT fields in PostgreSQL.
apps/​api/​internal/​storage/​dialect/​postgres/​token_test.go Updates PAT persistence fixtures.
apps/​api/​internal/​storage/​dialect/​postgres/​migration/​sql/​000064_personal_access_tokens.sql Adds PostgreSQL PAT columns.
apps/​api/​internal/​service/​personal_access_token.go Implements PAT lifecycle and verification.
apps/​api/​internal/​service/​flow_auth_request.go Requires consent for PAT creation scope.
apps/​api/​internal/​service/​flow_auth_request_test.go Tests first-party consent requirements.
apps/​api/​internal/​mcp/​sets_test.go Tests PAT tool-set membership.
apps/​api/​internal/​mcp/​handler.go Adds capability-dependent confirmation.
apps/​api/​internal/​mcp/​handler_test.go Tests PAT creation confirmation.
apps/​api/​internal/​mcp/​catalog.go Reads the confirmation marker.
apps/​api/​internal/​mcp/​catalog_test.go Pins confirmation and credential markers.
apps/​api/​internal/​domain/​token.go Adds PAT record fields and validation.
apps/​api/​internal/​domain/​token_test.go Tests PAT record requirements.
apps/​api/​internal/​domain/​personal_access_token.go Defines token format and constraints.
apps/​api/​internal/​domain/​personal_access_token_test.go Tests generation, parsing and constraints.
apps/​api/​internal/​domain/​event_payload.go Adds issuance type and expiry.
apps/​api/​internal/​domain/​consent_scope.go Marks creation scope as consent-required.
apps/​api/​internal/​api/​security.go Authenticates PATs with person-scoped access.
apps/​api/​internal/​api/​personal_access_token.go Implements the three API handlers.
apps/​api/​internal/​api/​integration_test/​helpers/​token.go Provides the PAT service helper.
apps/​api/​internal/​api/​integration_test/​helpers/​server.go Wires PAT integration-test services.
apps/​api/​internal/​api/​handler.go Adds the PAT service dependency.
apps/​api/​internal/​api/​generated/​oas_validators_gen.go Generates server-side validation.
apps/​api/​internal/​api/​generated/​oas_unimplemented_gen.go Adds generated handler stubs.
apps/​api/​internal/​api/​generated/​oas_server_gen.go Extends the server interface.
apps/​api/​internal/​api/​generated/​oas_security_gen.go Generates authentication mappings.
apps/​api/​internal/​api/​generated/​oas_response_encoders_gen.go Encodes PAT responses.
apps/​api/​internal/​api/​generated/​oas_request_decoders_gen.go Decodes creation requests.
apps/​api/​internal/​api/​generated/​oas_parameters_gen.go Decodes list and revoke parameters.
apps/​api/​internal/​api/​generated/​oas_operations_gen.go Adds server operation names.
apps/​api/​internal/​api/​generated/​oas_interfaces_gen.go Adds server response interfaces.
apps/​api/​internal/​api/​generated/​oas_cfg_gen.go Adds token-ID validation pattern.
apps/​api/​internal/​api/​error_handler.go Maps PAT errors to HTTP statuses.
apps/​api/​internal/​api/​authz_ungated_contract_internal_test.go Classifies own-credential operations.
apps/​api/​cmd/​server/​server.go Wires services behind the feature switch.
apps/​api/​cmd/​server/​config.go Defines PAT configuration.
apps/​api/​cmd/​server/​config_test.go Tests defaults and environment configuration.
apps/​api/​api/​openapi/​security/​oauth2.yaml Declares PAT scopes.
apps/​api/​api/​openapi/​openapi-spec.yaml Registers PAT routes.
apps/​api/​api/​openapi/​endpoints/​users/​me/​personal_access_tokens/​personal-access-token.yaml Defines public token metadata.
apps/​api/​api/​openapi/​endpoints/​users/​me/​personal_access_tokens/​methods.yaml Defines creation and listing contracts.
apps/​api/​api/​openapi/​endpoints/​users/​me/​personal_access_tokens/​listMyPersonalAccessTokens-error-response.yaml Generates listing error variants.
apps/​api/​api/​openapi/​endpoints/​users/​me/​personal_access_tokens/​list-personal-access-tokens-response.yaml Defines paginated listing responses.
apps/​api/​api/​openapi/​endpoints/​users/​me/​personal_access_tokens/​createMyPersonalAccessToken-error-response.yaml Generates creation error variants.
apps/​api/​api/​openapi/​endpoints/​users/​me/​personal_access_tokens/​create-personal-access-token-response.yaml Defines the one-time token response.
apps/​api/​api/​openapi/​endpoints/​users/​me/​personal_access_tokens/​create-personal-access-token-request.yaml Defines creation inputs and limits.
apps/​api/​api/​openapi/​endpoints/​users/​me/​personal_access_tokens/​by_id/​revokeMyPersonalAccessToken-error-response.yaml Generates revocation error variants.
apps/​api/​api/​openapi/​endpoints/​users/​me/​personal_access_tokens/​by_id/​methods.yaml Defines the revocation contract.
apps/​api/​api/​openapi/​endpoints/​events/​payloads/​auth-token-issued-payload.yaml Extends issuance event metadata.
apps/​api/​api/​openapi/​components/​schemas/​personal-access-token-id.yaml Defines the PAT identifier schema.
apps/​api/​api/​openapi/​components/​schemas/​errors/​tkn-pat_owner_not_platform.yaml Generates the owner restriction error.
apps/​api/​api/​openapi/​components/​schemas/​errors/​tkn-pat_not_found.yaml Generates the missing-token error.
apps/​api/​api/​openapi/​components/​schemas/​errors/​tkn-pat_invalid.yaml Generates the invalid-request error.
apps/​api/​api/​openapi/​components/​parameters/​personal-access-token-id.yaml Defines the revocation path parameter.
apps/​api/​api/​openapi/​components/​examples/​errors/​tkn-pat_owner_not_platform.yaml Adds an owner restriction example.
apps/​api/​api/​openapi/​components/​examples/​errors/​tkn-pat_not_found.yaml Adds a missing-token example.
apps/​api/​api/​openapi/​components/​examples/​errors/​tkn-pat_invalid.yaml Adds an invalid-request example.
apps/​api/​api/​openapi/​AGENTS.md Documents the MCP confirmation marker.
.changeset/​personal-access-tokens.md Adds server and API release notes.

Review effort: Balanced

content:
application/json:
schema:
$ref: ../../../../components/error-details.yaml
Comment on lines +110 to +114
err = s.pool.Transaction(ctx, func(ctx context.Context, tx Statementer[AllStatements]) error {
if err := s.underTheCap(ctx, tx.Statements(), record.UserID); err != nil {
return err
}
if err := tx.Statements().CreateToken(ctx, record); err != nil {
Comment on lines +148 to +169
// underTheCap refuses a PAT to a person who holds
// [domain.PersonalAccessTokenMaxLive] that have not expired. Expired ones
// stay until they are purged, so they are read and passed over, not counted.
func (s *personalAccessTokenService) underTheCap(ctx context.Context, stmts AllStatements, userID string) error {
newest, err := stmts.ListTokens(ctx, &database.ListOptions[domain.TokenField]{
Filter: database.And(
database.Equal(database.Col(domain.TokenFieldProjectID), s.platformProjectID),
database.Equal(database.Col(domain.TokenFieldUserID), userID),
database.Equal(database.Col(domain.TokenFieldType), domain.TokenTypePersonalAccessToken.String()),
),
Pagination: database.Page[domain.TokenField]{
Limit: capWindow,
OrderBy: database.OrderBy[domain.TokenField]{
Columns: []database.Column[domain.TokenField]{database.Col(domain.TokenFieldCreatedAt), database.Col(domain.TokenFieldTokenID)},
Direction: database.OrderDesc,
},
},
})
if err != nil {
return mapListError(err, "failed to count personal access tokens")
}
now, live := s.now(), 0
fforootd pushed a commit that referenced this pull request Dec 2, 2026
main holds this branch's bases as squash commits: the personal access token API (#3563), and before it ADR 095 (#3548) and the CLI's client document (#3558). The token API's squash has the tree of its branch's final head, which this branch already holds, so it is recorded as merged and nothing changes.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U
fforootd pushed a commit that referenced this pull request Dec 2, 2026
fforootd pushed a commit that referenced this pull request Dec 2, 2026
Brings in main with personal access tokens (#3563), so PR 2 can stack on
the ADR's branch. A scope granted only on the consent step
(personal_access_token.create, domain.ConsentRequired) is never
remembered and always shows the step, to a first-party client too; the
ADR says so. Generated files regenerated; sets_test lists both the token
tools and listMyConsents.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmUEzNb3SNs7Rj5USYf
@github-project-automation github-project-automation Bot moved this from Inbox to Done in Engineering Kanban Dec 2, 2026
fforootd pushed a commit that referenced this pull request Dec 2, 2026
…check

main gained personal access tokens (#3563) beside everything this branch's base already held. The server and the test harness wire both the operators' flag and the token service.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U

This branch was successfully deployed

1 active deployment
Preview — 377ba572 Deployed Dec 2, 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.

3 participants