Skip to content

feat: provision per-app system clients (admin-console, account-console) - #3371

Merged
tada5hi merged 3 commits into
masterfrom
feat/system-clients
Aug 2, 2026
Merged

tada5hi merged 3 commits into
masterfrom
feat/system-clients

Conversation

@tada5hi

@tada5hi tada5hi commented Aug 2, 2026 •

Copy link
Copy Markdown
Collaborator

What (plan 079)

Every realm now provisions three builtIn public PKCE clients instead of one:

Client Used by
web Downstream apps embedding client-web-kit (unchanged behavior)
admin-console The admin console's own login (client_id=admin-console, runtime-overridable via NUXT_PUBLIC_CLIENT_ID)
account-console The upcoming account self-service surface — provisioned ahead of it (web's <origin>/** patterns already cover every path it can redirect to, so the inert row adds no redirect surface)

Why

  • Admission control: an access policy bound to admin-console gates who may obtain tokens for the admin console without touching downstream logins. Left open by default — regular users still need the console's settings pages until the account surface ships; the restriction recipe (and its identity-data-only caveat) is documented in the provisioning guide.
  • Attribution: sessions and audit events carry the app they were issued for; per-app force-logout via filter[clientId].
  • Blast-radius split: per-app grantTypes, token-binding and post-logout allowlists.

How

  • web-client.ts → core/entities/client/system-clients.ts: definition-driven SYSTEM_CLIENT_DEFINITIONS + SystemClientProvisioner (same MERGE-owned attributes, dirty-check, takeover-and-warn, additive scope binding; both invocation sites — startup backfill + realm-create hook — unchanged).
  • displayName is seeded at CREATE only, never re-asserted; accessPolicyId stays out of the MERGE-owned set.
  • Redirect patterns stay the shared app-origin set for all three (deliberate: redirectUri is boot-reasserted, so a separately-hosted surface registers its origin via TRUSTED_ORIGINS).
  • CLIENT_RESERVED_NAMES grows to system, web, admin-console, account-console.
  • Docs: provisioning guide section rewritten (three clients + admission recipe), console configuration page documents NUXT_PUBLIC_CLIENT_ID, .agents/architecture.md updated.

Compat

No data migration. Existing web-bound sessions and refresh tokens keep working and age out; new console logins ride admin-console. A new console against an older server-core fails with invalid_client — releases are lockstep, noting it regardless.

Verification

  • Full server-core suite: 169 files / 1810 tests green (one key.spec failure in the first run reproduced the known shared-sqlite parallel-boot flake; passes in isolation and in the full rerun).
  • New/extended specs: provisioner definition matrix (create × merge × takeover × scopes × displayName-seeded-once), reserved names via it.each(CLIENT_RESERVED_NAMES), e2e authorize with client_id=admin-console + realm hint, e2e system-client provisioning on API realm-create, DB-level startup backfill for all three clients.
  • core-kit tests green; eslint clean.

Base #3370 has merged; this PR now targets master directly (rebased, single commit).

Summary by CodeRabbit

  • New Features

    • Added dedicated web, admin-console, and account-console clients for each realm.
    • Added configurable OAuth client selection for the admin console, defaulting to admin-console.
    • Added support for authorizing built-in console clients and provisioning them during realm creation.
  • Documentation

    • Updated provisioning, security, deployment, and client configuration guidance for the expanded system-client model.
  • Bug Fixes

    • Improved client takeover, scope assignment, redirect refresh, and reserved-name handling.

Copilot AI review requested due to automatic review settings August 2, 2026 14:01
@coderabbitai

coderabbitai Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@tada5hi, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 48 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 97a9c5b3-3438-43c1-b71a-f71d3cde3e22

📥 Commits

Reviewing files that changed from the base of the PR and between ba748b5 and 02c6a1b.

📒 Files selected for processing (3)
  • .agents/architecture.md
  • apps/authup/test/unit/packages/plan.spec.ts
  • docs/src/guide/deployment/provisioning.md
📝 Walkthrough

Walkthrough

The PR replaces the per-realm web-only client with three system clients: web, admin-console, and account-console. It updates provisioning, realm creation, admin-console OAuth configuration, reserved-name handling, tests, and deployment documentation.

Changes

System client provisioning

Layer / File(s) Summary
System client model and provisioner
packages/core-kit/src/domains/client/constants.ts, apps/server-core/src/core/entities/client/*
Defines the three built-in clients, shared scopes, client attributes, scope binding, takeover behavior, and generalized provisioner interfaces.
Realm provisioning and admin-console OAuth wiring
apps/server-core/src/core/entities/realm/service.ts, apps/server-core/src/app/modules/{http/modules/controller.ts,provisioning/module.ts}, apps/client-admin-console/*
Uses SystemClientProvisioner during realm creation and startup. The admin console reads a configurable client ID and defaults to admin-console.
Provisioning and authorization validation
apps/server-core/test/unit/core/entities/client/*, apps/server-core/test/unit/core/entities/realm/service.spec.ts, apps/server-core/test/unit/http/controllers/workflows/authorize.spec.ts, apps/server-core/test/unit/modules/provisioning.spec.ts
Tests three-client creation, scopes, redirects, idempotency, reserved names, takeover, authorization, and provisioning failure behavior.
System client documentation
.agents/architecture.md, docs/src/guide/deployment/*
Documents system-client roles, provisioning, reserved names, access policies, security behavior, and the NUXT_PUBLIC_CLIENT_ID override.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RealmAPI
  participant RealmService
  participant SystemClientProvisioner
  participant ClientAdminConsole
  participant AuthorizationWorkflow
  RealmAPI->>RealmService: create realm
  RealmService->>SystemClientProvisioner: ensureForRealm(realm)
  SystemClientProvisioner-->>RealmService: provision three system clients
  ClientAdminConsole->>AuthorizationWorkflow: authorize with configured clientId
  AuthorizationWorkflow-->>ClientAdminConsole: authorization response
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: provisioning per-app system clients for the admin console and account console.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/system-clients

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI 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.

Pull request overview

This PR implements plan 079 by moving from a single per-realm built-in public web client to a definition-driven set of per-realm system clients (web, admin-console, account-console) so Authup can apply per-app admission control, attribution, and grant/redirect allowlists without impacting downstream apps embedding @authup/client-web-kit.

Changes:

  • Introduces SystemClientProvisioner + SYSTEM_CLIENT_DEFINITIONS to provision/merge all per-realm system clients (startup backfill + realm-create hook).
  • Updates server-core tests to validate provisioning (create/merge/takeover), scope binding, reserved-name guardrails, and authorize flows using client_id=admin-console with realm hint.
  • Updates docs and client-console to use the dedicated admin-console client by default, with documentation for NUXT_PUBLIC_CLIENT_ID.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/core-kit/src/domains/client/constants.ts Adds admin-console and account-console client name constants and reserves them.
docs/src/guide/deployment/provisioning.md Updates provisioning guide to describe the three per-realm system clients and the admin-console restriction recipe.
docs/src/guide/deployment/configuration-client-console.md Documents NUXT_PUBLIC_CLIENT_ID for console authentication client selection.
apps/server-core/test/unit/modules/provisioning.spec.ts Extends provisioning module tests to assert new system clients exist and have scopes/displayName.
apps/server-core/test/unit/http/controllers/workflows/authorize.spec.ts Adds e2e-ish coverage for admin-console authorize by name + realm hint and realm-create provisioning.
apps/server-core/test/unit/core/entities/realm/service.spec.ts Updates realm service wiring tests to use ISystemClientProvisioner.
apps/server-core/test/unit/core/entities/client/system-clients.spec.ts Adds/updates unit tests for system client definitions, attributes, scope binding, merge/takeover behavior.
apps/server-core/test/unit/core/entities/client/service.spec.ts Updates reserved-name guardrail test to cover all reserved names via CLIENT_RESERVED_NAMES.
apps/server-core/src/core/entities/realm/service.ts Replaces web-client provisioning hook with system-client provisioning hook during realm create.
apps/server-core/src/core/entities/client/types.ts Introduces SystemClientDefinition and renames provisioner interface to ISystemClientProvisioner.
apps/server-core/src/core/entities/client/system-clients.ts Implements definition-driven system client provisioning (create/merge/takeover + additive scope binding).
apps/server-core/src/core/entities/client/index.ts Switches entity exports from web-client.ts to system-clients.ts.
apps/server-core/src/app/modules/provisioning/module.ts Updates startup provisioning to ensure all system clients per realm.
apps/server-core/src/app/modules/http/modules/controller.ts Updates runtime realm-create hook wiring to use SystemClientProvisioner.
apps/client-console/pages/logout.vue Updates comment to reference admin-console as the name-identified client.
apps/client-console/pages/login/index.vue Uses runtime-configured clientId instead of hardcoded web for login redirects/requests.
apps/client-console/nuxt.config.ts Adds default console clientId (admin-console) and documents runtime override intent.
.agents/architecture.md Updates architecture documentation to reflect per-realm system clients and new provisioner behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +96 to +100
// The OAuth2 client the console authenticates against — the
// per-realm built-in `admin-console` client (plan 079).
// Runtime-overridable via NUXT_PUBLIC_CLIENT_ID for forks that
// register their own client.
clientId: process.env.CLIENT_ID || CLIENT_ADMIN_CONSOLE_NAME,
@pkg-pr-new

pkg-pr-new Bot commented Aug 2, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

authup

npm i https://pkg.pr.new/authup/authup@3371

@authup/client-admin-console

npm i https://pkg.pr.new/authup/authup/@authup/client-admin-console@3371

@authup/server-core

npm i https://pkg.pr.new/authup/authup/@authup/server-core@3371

@authup/access

npm i https://pkg.pr.new/authup/authup/@authup/access@3371

@authup/client-web-kit

npm i https://pkg.pr.new/authup/authup/@authup/client-web-kit@3371

@authup/client-web-kit-theme

npm i https://pkg.pr.new/authup/authup/@authup/client-web-kit-theme@3371

@authup/client-web-nuxt

npm i https://pkg.pr.new/authup/authup/@authup/client-web-nuxt@3371

@authup/client-web-theme

npm i https://pkg.pr.new/authup/authup/@authup/client-web-theme@3371

@authup/core-http-kit

npm i https://pkg.pr.new/authup/authup/@authup/core-http-kit@3371

@authup/core-kit

npm i https://pkg.pr.new/authup/authup/@authup/core-kit@3371

@authup/core-realtime-kit

npm i https://pkg.pr.new/authup/authup/@authup/core-realtime-kit@3371

@authup/errors

npm i https://pkg.pr.new/authup/authup/@authup/errors@3371

@authup/i18n

npm i https://pkg.pr.new/authup/authup/@authup/i18n@3371

@authup/kit

npm i https://pkg.pr.new/authup/authup/@authup/kit@3371

@authup/server-adapter-kit

npm i https://pkg.pr.new/authup/authup/@authup/server-adapter-kit@3371

@authup/server-adapter-node

npm i https://pkg.pr.new/authup/authup/@authup/server-adapter-node@3371

@authup/server-adapter-socket-io

npm i https://pkg.pr.new/authup/authup/@authup/server-adapter-socket-io@3371

@authup/server-adapter-web

npm i https://pkg.pr.new/authup/authup/@authup/server-adapter-web@3371

@authup/server-kit

npm i https://pkg.pr.new/authup/authup/@authup/server-kit@3371

@authup/server-test-kit

npm i https://pkg.pr.new/authup/authup/@authup/server-test-kit@3371

@authup/specs

npm i https://pkg.pr.new/authup/authup/@authup/specs@3371

commit: 6dda180

@tada5hi
tada5hi force-pushed the refactor/client-console branch from 6741c4e to 701d6b1 Compare August 2, 2026 16:06
@tada5hi
tada5hi force-pushed the feat/system-clients branch from 592ef42 to 93336d8 Compare August 2, 2026 16:08
Base automatically changed from refactor/client-console to master August 2, 2026 16:10
Every realm now provisions three builtIn public PKCE clients (plan 079):
web (downstream apps embedding client-web-kit), admin-console (the
admin console's own login client; runtime-overridable via
NUXT_PUBLIC_CLIENT_ID) and account-console (provisioned ahead of the
account surface). The web client provisioner generalizes into a
definition-driven SystemClientProvisioner; displayName is seeded at
create only, accessPolicyId stays admin-owned, and both new names join
CLIENT_RESERVED_NAMES.

The split enables per-app admission control (an access policy bound to
admin-console no longer affects downstream logins), per-app session and
audit attribution by clientId, and per-app grant/redirect/logout
allowlists. No data migration: existing web-bound sessions and refresh
tokens keep working and age out.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🧹 Nitpick comments (1)
apps/server-core/src/app/modules/provisioning/module.ts (1)

228-255: 🚀 Performance & Scalability | 🔵 Trivial

Startup provisioning cost scales with realm count times client count.

The per-realm loop (Lines 251-255) now triggers up to 3x more sequential DB round trips per realm than before, since each realm provisions three system clients instead of one, and each client involves a client lookup plus per-scope lookups and junction-row lookups. This runs on every boot for every existing realm, on the path before the server accepts traffic. For deployments with many realms, this can noticeably lengthen startup time. Consider whether provisioning should run out-of-band (background job) or be parallelized/batched for large realm counts if this becomes an issue in practice.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/server-core/src/app/modules/provisioning/module.ts` around lines 228 -
255, Update the startup provisioning flow around the realms loop and
SystemClientProvisioner.ensureForRealm so provisioning does not block server
readiness with sequential per-realm, per-client database work. Move this work to
an out-of-band startup task or parallelize/batch the realm provisioning while
preserving ensureForRealm behavior and completing key provisioning for every
realm.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.agents/architecture.md:
- Around line 1964-1966: Update the documentation around
buildSystemClientAttributes and SystemClientProvisioner to refer to all system
clients—web, admin-console, and account-console—instead of only web. Clarify
that accessPolicyId remains admin-controlled and that the grant allowlist is
refreshed for every system client, including the related references at the
additional location.

In `@docs/src/guide/deployment/provisioning.md`:
- Around line 20-24: Update both deployment guide descriptions around the
authorization-code flow and the corresponding second description to state that
accessPolicyId is enforced only when admitting and redeeming authorization
codes, not for refresh_token grants. Clarify that existing refresh tokens remain
usable until expiry or session revocation, and instruct operators to revoke
sessions when evicting identities already admitted by the client.

---

Nitpick comments:
In `@apps/server-core/src/app/modules/provisioning/module.ts`:
- Around line 228-255: Update the startup provisioning flow around the realms
loop and SystemClientProvisioner.ensureForRealm so provisioning does not block
server readiness with sequential per-realm, per-client database work. Move this
work to an out-of-band startup task or parallelize/batch the realm provisioning
while preserving ensureForRealm behavior and completing key provisioning for
every realm.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f93b4756-2ad0-4cab-8f9d-2686ced04ac4

📥 Commits

Reviewing files that changed from the base of the PR and between 77d48a4 and ba748b5.

📒 Files selected for processing (18)
  • .agents/architecture.md
  • apps/client-admin-console/nuxt.config.ts
  • apps/client-admin-console/pages/login/index.vue
  • apps/client-admin-console/pages/logout.vue
  • apps/server-core/src/app/modules/http/modules/controller.ts
  • apps/server-core/src/app/modules/provisioning/module.ts
  • apps/server-core/src/core/entities/client/index.ts
  • apps/server-core/src/core/entities/client/system-clients.ts
  • apps/server-core/src/core/entities/client/types.ts
  • apps/server-core/src/core/entities/realm/service.ts
  • apps/server-core/test/unit/core/entities/client/service.spec.ts
  • apps/server-core/test/unit/core/entities/client/system-clients.spec.ts
  • apps/server-core/test/unit/core/entities/realm/service.spec.ts
  • apps/server-core/test/unit/http/controllers/workflows/authorize.spec.ts
  • apps/server-core/test/unit/modules/provisioning.spec.ts
  • docs/src/guide/deployment/configuration-client-admin-console.md
  • docs/src/guide/deployment/provisioning.md
  • packages/core-kit/src/domains/client/constants.ts

Comment thread .agents/architecture.md Resolved
tada5hi added 2 commits August 2, 2026 18:17
…lector

The rename sweep updated the string literals but not the escaped regex
literals (/client\.console/), leaving two launcher unit tests failing on
master.
… clients

Review follow-ups on #3371: the provisioning guide now states that a
client access policy gates admission (code flow + redemption) only —
refresh tokens are not re-evaluated; revoke sessions to evict — and the
architecture guide's accessPolicyId / grant-allowlist notes now speak of
every system client instead of web only.
@tada5hi
tada5hi merged commit 140e9d2 into master Aug 2, 2026
7 checks passed
@tada5hi
tada5hi deleted the feat/system-clients branch August 2, 2026 16:24
@github-actions github-actions Bot mentioned this pull request Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants