Skip to content

fix(api): close the remembered-consent review findings - #3584

Merged
fforootd merged 6 commits into
mainfrom
claude/remembered-consent
Dec 2, 2026
Merged

fforootd merged 6 commits into
mainfrom
claude/remembered-consent

Conversation

@fforootd

@fforootd fforootd commented Dec 2, 2026 •

Copy link
Copy Markdown
Member

Context

Summary

  • Postgres revoke race. A consent revoked while one of its client's codes was being redeemed could leave that redemption's refresh grant alive: the revoke read with one snapshot, taken before it waited on the code. Codes and grants now end in separate statements, codes first, so the grant delete reads after the wait.
  • Remembered only for the client shown. The consent step's client digest is sealed in the flow state and handed back with the answer. An answer for a client whose metadata document changed while the step showed still gets its code, but it is not remembered, so a later request cannot skip for a client the person never saw. Flows sealed before the deploy carry no digest, so their answers are not remembered once.
  • Reload and CLI. A reload that finds the consent step's client changed restarts the flow. The built-in CLI client now has a digest, and an answer that names no shown client is not remembered.
  • Spec. listMyConsents documents its 403 auth.scope_insufficient answer with the shared error details, as identity links does, so the generated clients decode it.

Validation

Run by the writing session:

  • go-generate --check, go vet with each tag, go test ./..., the Go client module's tests, the SQLite lane and the PostgreSQL 16 lane on a fresh database.
  • A new statement test reproduces the revoke race with a real redemption transaction; it fails on the old statement and is skipped on SQLite, which runs one transaction at a time. The digest rule has an engine test and a service test, the spec change a Go client test. Each was checked to fail without its fix.
  • Not run: the Spanner lane.

Release notes / changeset

Notes

  • Known, not addressed: two concurrent answers by the same person write last-wins, which can restore a scope they declined in another tab; and a revoke that lands between the consent read and the code issue lets that one in-flight sign-in still get its code. Both need the person racing themselves.
  • Written in the session https://claude.ai/code/session_0137eGmUEzNb3SNs7Rj5USYf; this draft was opened by the coordinating session below.

https://claude.ai/code/session_0137eGmVSt2DgYJj2CjZbi1U


Generated by Claude Code

The consent skip setting is a follow-up to an unreleased change, so its note
joins that change's entry (.changeset/README.md).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmUEzNb3SNs7Rj5USYf
…evoked

On Postgres the revoke was one statement, reading with one snapshot taken
before it waited on a redemption's code: the grant that redemption then
committed survived. The codes now end before the grants, each in its own
statement, so the grant delete reads after the wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmUEzNb3SNs7Rj5USYf
The answer was stored under the client's digest when it came in. A client
whose metadata document changed while the step showed was then remembered for
the person, who never saw it. The flow now keeps the digest of the client the
step showed, and an answer for a client that changed since is answered but
not remembered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmUEzNb3SNs7Rj5USYf
… shared error

A person's token without user.read is answered 403 auth.scope_insufficient,
but the spec's 403 allowed only sess.project_mismatch, so the generated Go
client could not read it. The 403 now takes the shared error details, as
identity links' does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmUEzNb3SNs7Rj5USYf
@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 8:25pm UTC

Request Review

@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

🦋 Changeset detected

Latest commit: 91d0552

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

@fforootd
fforootd marked this pull request as ready for review December 2, 2026 20:09
Copilot AI balanced review requested due to automatic review settings December 2, 2026 20:09
@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-02T20:21:35.761147Z 9b88605 Draft marked ready
ℹ️ 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.

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

Empty CLI digests allow answers to be remembered without a sealed client identity, while consent-page reloads can leave stale digests that prevent remembering answers or associate them with the wrong client.

2 open issues
1 file not reviewed
  • packages/go/api/oas_response_decoders_gen.go: Generated file
What changed in this PR

Addresses remembered-consent follow-ups to #3574, complementing the hosted-cloud skip gate from #3583.

Changes:

  • Orders PostgreSQL revocation statements to catch refresh grants created by concurrent code redemption.
  • Carries the displayed client’s digest through consent flow state.
  • Corrects consent-list error schemas, adds regression tests, and consolidates release notes.
File Description
packages/​go/​api/​oas_schemas_gen.go Regenerates client error types.
packages/​go/​api/​oas_response_decoders_gen.go Updates consent-list error decoding.
packages/​go/​api/​oas_json_gen.go Adds generated error serialization.
packages/​go/​api/​client_test.go Tests insufficient-scope response decoding.
apps/​api/​internal/​storage/​stmttest/​consent_test.go Tests revocation during code redemption.
apps/​api/​internal/​storage/​dialect/​postgres/​consent.go Deletes codes before refresh grants transactionally.
apps/​api/​internal/​service/​flow_auth_request.go Checks the displayed client digest before remembering consent.
apps/​api/​internal/​service/​flow_auth_request_test.go Checks consent digest population.
apps/​api/​internal/​service/​flow_auth_request_remembered_test.go Tests changed-client consent handling.
apps/​api/​internal/​flowengine/​state.go Stores the displayed client digest.
apps/​api/​internal/​flowengine/​auth_request.go Passes the digest through consent processing.
apps/​api/​internal/​flowengine/​auth_request_test.go Tests digest propagation into answers.
apps/​api/​internal/​api/​generated/​oas_schemas_gen.go Regenerates server error types.
apps/​api/​internal/​api/​generated/​oas_response_encoders_gen.go Updates consent-list response encoding.
apps/​api/​internal/​api/​generated/​oas_json_gen.go Adds generated error serialization.
apps/​api/​api/​openapi/​endpoints/​users/​me/​consents/​methods.yaml Documents shared 403 error details.
apps/​api/​api/​openapi/​bundled/​openapi.json Refreshes the bundled API contract.
.changeset/​oauth-remembered-consent.md Incorporates consent-skip release notes.
.changeset/​oauth-consent-skip.md Removes the consolidated changeset.

Review effort: Balanced

state.ConsentScopes = append(make([]string, 0, len(consent.Granted)), consent.Granted...)
return nil, nil
}
state.ConsentDigest = consent.Digest
}
// The client changed while the step showed: the person answered for the
// client they saw, and a later request of this one starts from nothing.
if in.ShownDigest != client.Digest {
A reload renders the consent step from state that is not sealed again, so the
flow kept the client digest of the first showing while the screen showed the
client as it is now. A reload that finds another client now restarts the
flow instead of answering for one client while showing another.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmUEzNb3SNs7Rj5USYf
… one

The built-in CLI client had no digest, so a CLI flow sealed before the flow
kept the shown client matched on two empty digests and was remembered. The CLI
now has a digest like every other client, and an answer that names no shown
client is answered but not remembered.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0137eGmUEzNb3SNs7Rj5USYf
@fforootd
fforootd added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit 5d6290b Dec 2, 2026
18 checks passed
@fforootd
fforootd deleted the claude/remembered-consent branch December 2, 2026 20:45
@github-project-automation github-project-automation Bot moved this from Inbox to Done in Engineering Kanban Dec 2, 2026

This branch was successfully deployed

1 active deployment
Preview — 91d05527 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