Repository navigation
feat: provision per-app system clients (admin-console, account-console) - #3371
Conversation
|
Warning Review limit reached
Next review available in: 48 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR replaces the per-realm web-only client with three system clients: ChangesSystem client provisioning
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
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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_DEFINITIONSto 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-consolewith realm hint. - Updates docs and client-console to use the dedicated
admin-consoleclient by default, with documentation forNUXT_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.
| // 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, |
authup
@authup/client-admin-console
@authup/server-core
@authup/access
@authup/client-web-kit
@authup/client-web-kit-theme
@authup/client-web-nuxt
@authup/client-web-theme
@authup/core-http-kit
@authup/core-kit
@authup/core-realtime-kit
@authup/errors
@authup/i18n
@authup/kit
@authup/server-adapter-kit
@authup/server-adapter-node
@authup/server-adapter-socket-io
@authup/server-adapter-web
@authup/server-kit
@authup/server-test-kit
@authup/specs
commit: |
6741c4e to
701d6b1
Compare
592ef42 to
93336d8
Compare
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.
93336d8 to
ba748b5
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/server-core/src/app/modules/provisioning/module.ts (1)
228-255: 🚀 Performance & Scalability | 🔵 TrivialStartup 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
📒 Files selected for processing (18)
.agents/architecture.mdapps/client-admin-console/nuxt.config.tsapps/client-admin-console/pages/login/index.vueapps/client-admin-console/pages/logout.vueapps/server-core/src/app/modules/http/modules/controller.tsapps/server-core/src/app/modules/provisioning/module.tsapps/server-core/src/core/entities/client/index.tsapps/server-core/src/core/entities/client/system-clients.tsapps/server-core/src/core/entities/client/types.tsapps/server-core/src/core/entities/realm/service.tsapps/server-core/test/unit/core/entities/client/service.spec.tsapps/server-core/test/unit/core/entities/client/system-clients.spec.tsapps/server-core/test/unit/core/entities/realm/service.spec.tsapps/server-core/test/unit/http/controllers/workflows/authorize.spec.tsapps/server-core/test/unit/modules/provisioning.spec.tsdocs/src/guide/deployment/configuration-client-admin-console.mddocs/src/guide/deployment/provisioning.mdpackages/core-kit/src/domains/client/constants.ts
…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.
What (plan 079)
Every realm now provisions three builtIn public PKCE clients instead of one:
webclient-web-kit(unchanged behavior)admin-consoleclient_id=admin-console, runtime-overridable viaNUXT_PUBLIC_CLIENT_ID)account-consoleweb's<origin>/**patterns already cover every path it can redirect to, so the inert row adds no redirect surface)Why
admin-consolegates 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.filter[clientId].grantTypes, token-binding and post-logout allowlists.How
web-client.ts→core/entities/client/system-clients.ts: definition-drivenSYSTEM_CLIENT_DEFINITIONS+SystemClientProvisioner(same MERGE-owned attributes, dirty-check, takeover-and-warn, additive scope binding; both invocation sites — startup backfill + realm-create hook — unchanged).displayNameis seeded at CREATE only, never re-asserted;accessPolicyIdstays out of the MERGE-owned set.redirectUriis boot-reasserted, so a separately-hosted surface registers its origin viaTRUSTED_ORIGINS).CLIENT_RESERVED_NAMESgrows tosystem, web, admin-console, account-console.NUXT_PUBLIC_CLIENT_ID,.agents/architecture.mdupdated.Compat
No data migration. Existing
web-bound sessions and refresh tokens keep working and age out; new console logins rideadmin-console. A new console against an older server-core fails withinvalid_client— releases are lockstep, noting it regardless.Verification
key.specfailure in the first run reproduced the known shared-sqlite parallel-boot flake; passes in isolation and in the full rerun).it.each(CLIENT_RESERVED_NAMES), e2e authorize withclient_id=admin-console+ realm hint, e2e system-client provisioning on API realm-create, DB-level startup backfill for all three clients.Base #3370 has merged; this PR now targets master directly (rebased, single commit).
Summary by CodeRabbit
New Features
web,admin-console, andaccount-consoleclients for each realm.admin-console.Documentation
Bug Fixes