Skip to content

feat: store applications, their revisions and client credentials - #2900

Merged
gayathri-r-v merged 26 commits into
mainfrom
feat/applications-storage
Nov 12, 2026
Merged

gayathri-r-v merged 26 commits into
mainfrom
feat/applications-storage

Conversation

@gayathri-r-v

@gayathri-r-v gayathri-r-v commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Context

Summary

The second of three PRs for #2788. It adds the domain rules and storage for
registered applications; the service and API follow in the next PR.

  • Domain:
    • ValidateApplicationDocument checks the rules application.json
      describes but cannot enforce:
      • no slug or client_id used twice in one document
      • refresh_token only with authorization_code
      • at least one redirect URI for authorization_code
      • redirect URIs in canonical form, with no fragment and http only on
        loopback hosts
    • ApplicationClientsToCreate(current, document) returns the slugs of the
      clients a write adds; on create, current is empty.
      • A revision may not remove a client or change a client's client_id;
        application.field_immutable lists every case in {"fields": [...]}.
      • A client sent without its client_id keeps the one it has.
      • Only a new client is refused a client_ or dcr_ prefix;
        application.invalid lists every such client.
  • Tables in all three dialects:
    • applications holds what is fixed for an application's life: id, slug
      and creation time.
    • application_revisions gets a row with the document on every write; the
      newest by created_at is the current one (ADR 063).
    • application_clients holds one row per client with its client_id,
      unique per project.
    • application_client_secrets holds each client's secret hashes, with a
      foreign key to the client.
  • ApplicationStatements:
    • create and revise in one transaction with the new clients, lock, get at
      the newest revision by id or slug
    • list an application's clients, look up a client by client_id
    • create a client secret, list a client's secrets oldest first
    • A client without a client_id gets a copy of its generated client_*
      key (ADR 047 §5).
    • Every create and revise fills each client's client_id from its row into
      the stored document, including a stored client's id that the revision
      leaves out, so a revision can send a generated id back unchanged.

Validation

  • cd apps/api && go build ./... && go test ./internal/domain/... ./internal/service/... ./internal/storage/...
  • go test -tags {sqlite,postgres}_integration ./internal/storage/stmttest/ -run 'TestApplicationStatements|TestSchemaNullabilityMatchesDDL'
  • go test -tags {sqlite,postgres}_integration ./internal/storage/dialect/*/migration/... (migration round trip)
  • moon run server:generate, moon run server:check-generate-pruned

Release notes / changeset

  • Changeset: .changeset/applications-storage.md — @zitadel/server minor:
    the server stores applications, their revisions and client credentials;
    the endpoints still return not implemented.

Notes

  • Base of a stack: feat: create, revise and read registered applications #2901 builds the service and API on top of this PR.
  • A create or revise can trip three unique indexes in one transaction, and
    Spanner reports an empty constraint name. The service PR (feat: create, revise and read registered applications #2901) tells the
    cases apart by reading state after the transaction has ended:
    • on a create it reads the slug first and revises the application another
      caller created, then checks the client_id
    • on a revise it checks the client_id, and anything else is
      revision_conflict
  • Errors:
  • Secrets:
    • They have their own table, like user passwords, so a client can hold more
      than one.
    • The client and its secret are written in the same transaction. The secret
      has its own statement because it needs the client's row id, which the
      client insert sets.
    • The stored document never holds a secret or its hash; the schema refuses
      any field it does not define.
    • There is no delete statement yet, so no rotation.
  • The cascade from applications frees a client_id and deletes the
    client's secrets when an application is deleted. The PR that adds deletion
    owns the contract's promise that an id once held is never reused.
  • A revise that fails on a client insert rolls back its revision; the
    statement sets the new revision id and the filled document on the entity
    only after every write succeeds.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Nov 9, 2026

Copy link
Copy Markdown

Deployment failed for project cloud with the following error:

You don't have permission to create a Preview Deployment for this Vercel project: cloud.

View Documentation: https://vercel.com/docs/accounts/team-members-and-roles

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

🦋 Changeset detected

Latest commit: 8b832fb

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

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

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

@gayathri-r-v
gayathri-r-v force-pushed the feat/applications-storage branch from e25ea61 to d38c60d Compare November 9, 2026 14:43
@gayathri-r-v
gayathri-r-v force-pushed the feat/applications-storage branch from dd070f8 to fe6ca05 Compare November 10, 2026 10:37
Base automatically changed from feat/applications-api to main November 10, 2026 10:41
@gayathri-r-v
gayathri-r-v force-pushed the feat/applications-storage branch from fe6ca05 to f300f1d Compare November 10, 2026 10:51
@gayathri-r-v
gayathri-r-v added this pull request to stack #2924 November 10, 2026 10:52
@gayathri-r-v
gayathri-r-v marked this pull request as ready for review November 10, 2026 11:36
Copilot AI balanced review requested due to automatic review settings November 10, 2026 11:36

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@wim07101993
wim07101993 self-requested a review November 10, 2026 11:49
@wim07101993 wim07101993 moved this from Inbox to In progress in Engineering Kanban Nov 10, 2026
@wim07101993 wim07101993 self-assigned this Nov 10, 2026
Comment thread apps/api/internal/domain/application.go Resolved
Comment thread apps/api/internal/domain/application.go Resolved
Comment thread apps/api/internal/domain/application.go Resolved
Comment thread apps/api/internal/domain/application.go Resolved
@gayathri-r-v
gayathri-r-v force-pushed the feat/applications-storage branch 2 times, most recently from 3a7d45c to b7879c8 Compare November 11, 2026 09:17

@wim07101993 wim07101993 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Migraiton number clash

Comment thread apps/api/internal/domain/application.go Resolved
@wim07101993 wim07101993 linked an issue Nov 12, 2026 that may be closed by this pull request
6 tasks
gayathri-r-v and others added 7 commits November 12, 2026 11:16
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gayathri-r-v and others added 15 commits November 12, 2026 11:16
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… what the application row holds

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ort every immutable field

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

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…pt migrations

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@gayathri-r-v
gayathri-r-v added this pull request to the merge queue Nov 12, 2026
@gayathri-r-v
gayathri-r-v removed this pull request from the merge queue due to a manual request Nov 12, 2026
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@gayathri-r-v
gayathri-r-v enabled stacked auto-merge November 12, 2026 11:40
stacked auto-merge was automatically disabled November 12, 2026 11:40

Replaced by a newer auto-merge request

@gayathri-r-v
gayathri-r-v enabled stacked auto-merge November 12, 2026 11:40
@gayathri-r-v
gayathri-r-v added this pull request to the merge queue Nov 12, 2026
Merged via the queue into main with commit 39ebc7f Nov 12, 2026
18 of 20 checks passed
@gayathri-r-v
gayathri-r-v deleted the feat/applications-storage branch November 12, 2026 11:52
@github-project-automation github-project-automation Bot moved this from In progress to Done in Engineering Kanban Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Applications: create and read registered applications with their OAuth clients

3 participants