Repository navigation
feat: per-realm web client login, realm chooser & backend-served auth workflow UI - #3104
Conversation
Auto-provision a public OAuth2 client named `web` for every realm (public, PKCE, built_in, scope `global openid`) at startup and on runtime realm creation, and turn client-web `/login` into a realm chooser that drives the auth-code + PKCE flow against that client. - core-kit: CLIENT_WEB_NAME / CLIENT_RESERVED_NAMES constants - server-core: WebClientProvisioner (idempotent, built_in-guarded), startup + RealmService runtime hook, reserved-name guard in ClientService, ADDITIONAL_DOMAINS config + getAppOrigins, CORS origin allowlist derived from trusted app origins - client-web-kit: PKCE/state + authorization-request helpers, buildAuthorizeURL, ARealmGrid, SSR auto-consent for built_in clients, exchangeAuthorizationCode accepts code_verifier / redirect_uri / client_id / realm_id - client-web-nuxt: routing interceptor verifies state and replays the stored PKCE request at the token exchange - client-web: /login realm grid + /login/callback - docs + .agents/architecture.md
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughImplements per-realm automatic provisioning of a built-in public OAuth2 ChangesPer-Realm Web Client Provisioning with Realm Selection Login
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
authup
@authup/client-web
@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: |
There was a problem hiding this comment.
Pull request overview
This PR introduces a per-realm, built-in public OAuth2 client (web) and updates the web login flow to a realm-selection + authorization-code-with-PKCE flow, while tightening CORS/redirect origin allowlists based on PUBLIC_URL and ADDITIONAL_DOMAINS.
Changes:
- Auto-provision a built-in public
webclient for every realm (startup reconciliation + runtime realm creation hook) and reserveweb/systemclient names from API callers. - Switch client-web login to a realm chooser that initiates auth-code + PKCE and persists the authorization request for callback exchange/validation.
- Restrict CORS origins (and
webredirect allowlist origins) to trusted origins derived frompublicUrl+additionalDomains.
Reviewed changes
Copilot reviewed 38 out of 38 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/core-kit/src/domains/client/index.ts | Re-exports client constants to make reserved names available from core-kit. |
| packages/core-kit/src/domains/client/constants.ts | Adds system/web reserved client name constants. |
| packages/client-web-nuxt/src/runtime/helpers/routing-interceptor.ts | Enhances callback handling: loads stored auth request, validates state, and exchanges code with PKCE parameters. |
| packages/client-web-kit/src/core/store/create.ts | Extends exchangeAuthorizationCode to accept PKCE/client/realm params. |
| packages/client-web-kit/src/core/oauth2/pkce.ts | Adds PKCE + state generation helpers for auth-code flow. |
| packages/client-web-kit/src/core/oauth2/index.ts | Exports new OAuth2 helper modules. |
| packages/client-web-kit/src/core/oauth2/authorization-request.ts | Adds sessionStorage persistence for state/PKCE/redirect replay and authorize URL builder. |
| packages/client-web-kit/src/core/index.ts | Exposes OAuth2 helpers from the package’s core barrel. |
| packages/client-web-kit/src/components/workflows/authorize/AuthorizeForm.vue | Adds auto-consent for built_in clients in the SSR authorize UI. |
| packages/client-web-kit/src/components/entities/realm/index.ts | Exports the new realm grid component. |
| packages/client-web-kit/src/components/entities/realm/ARealmGrid.vue | Adds a simple realm picker grid (unauthenticated realms listing). |
| docs/src/guide/deployment/provisioning.md | Documents per-realm web client behavior and trusted origins concept. |
| docs/src/guide/deployment/configuration-server-core.md | Documents additionalDomains / ADDITIONAL_DOMAINS and its security implications. |
| docs/src/guide/deployment/configuration-client-web.md | Documents production requirements for UI origin allowlisting. |
| apps/server-core/test/unit/core/entities/realm/service.spec.ts | Adds coverage ensuring realm-create triggers web client provisioning when wired. |
| apps/server-core/test/unit/core/entities/client/web-client.spec.ts | Adds unit tests for web client attribute building and idempotent provisioning behavior. |
| apps/server-core/test/unit/core/entities/client/service.spec.ts | Adds tests for reserved-name guardrails and stripping built_in on create. |
| apps/server-core/test/unit/config/index.spec.ts | Adds tests for deriving/deduping trusted app origins from config. |
| apps/server-core/src/core/entities/realm/service.ts | Wires runtime provisioning hook into realm creation via IWebClientProvisioner. |
| apps/server-core/src/core/entities/client/web-client.ts | Implements WebClientProvisioner and buildWebClientAttributes for per-realm web client upsert. |
| apps/server-core/src/core/entities/client/types.ts | Introduces IWebClientProvisioner interface. |
| apps/server-core/src/core/entities/client/service.ts | Adds reserved client-name rejection for API create/update flows. |
| apps/server-core/src/core/entities/client/index.ts | Exports web-client provisioner utilities. |
| apps/server-core/src/app/modules/provisioning/module.ts | Adds startup reconciliation to upsert the web client for every realm. |
| apps/server-core/src/app/modules/http/modules/middleware.ts | Restricts CORS to trusted origins by default (unless explicitly configured). |
| apps/server-core/src/app/modules/http/modules/controller.ts | Injects a web-client provisioner into the realm controller/service wiring. |
| apps/server-core/src/app/modules/config/types.ts | Adds additionalDomains to server-core config type. |
| apps/server-core/src/app/modules/config/read/env.ts | Reads ADDITIONAL_DOMAINS from env into config input. |
| apps/server-core/src/app/modules/config/parse.ts | Validates additionalDomains as URL array. |
| apps/server-core/src/app/modules/config/origins.ts | Adds getAppOrigins() helper to derive/dedupe bare origins. |
| apps/server-core/src/app/modules/config/normalize.ts | Seeds localhost:3000 in non-production and normalizes additionalDomains. |
| apps/server-core/src/app/modules/config/index.ts | Re-exports getAppOrigins(). |
| apps/server-core/src/app/modules/config/constants.ts | Adds ADDITIONAL_DOMAINS env var constant. |
| apps/server-core/src/adapters/http/middleware/built-in/cors.ts | Clarifies CORS origin behavior and keeps options merge behavior. |
| apps/client-web/pages/login/index.vue | Replaces login screen with realm chooser that initiates auth-code + PKCE. |
| apps/client-web/pages/login/callback.vue | Adds callback route that relies on routing interceptor exchange + redirects home. |
| apps/client-web/pages/login.vue | Removes the previous login page implementation. |
| .agents/architecture.md | Documents the new per-realm web client and realm-selection login architecture. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (3)
packages/client-web-kit/src/core/oauth2/authorization-request.ts (1)
26-28: 💤 Low valueConsider extracting the sessionStorage guard into a helper.
The
typeof sessionStorage === 'undefined'check is repeated in three functions. Extracting it to a small helper would improve maintainability and make the intent clearer.♻️ Proposed refactor
+function isSessionStorageAvailable(): boolean { + return typeof sessionStorage !== 'undefined'; +} + export function saveAuthorizationRequest(request: AuthorizationRequest): void { - if (typeof sessionStorage === 'undefined') { + if (!isSessionStorageAvailable()) { return; } sessionStorage.setItem(STORAGE_KEY, JSON.stringify(request)); } export function loadAuthorizationRequest(): AuthorizationRequest | undefined { - if (typeof sessionStorage === 'undefined') { + if (!isSessionStorageAvailable()) { return undefined; } // ... } export function clearAuthorizationRequest(): void { - if (typeof sessionStorage === 'undefined') { + if (!isSessionStorageAvailable()) { return; } sessionStorage.removeItem(STORAGE_KEY); }Also applies to: 34-36, 51-53
🤖 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 `@packages/client-web-kit/src/core/oauth2/authorization-request.ts` around lines 26 - 28, Extract the repeated guard into a small helper named isSessionStorageAvailable(): boolean in authorization-request.ts and replace the three occurrences of if (typeof sessionStorage === 'undefined') { return; } with if (!isSessionStorageAvailable()) { return; } (or guard-return as appropriate) inside the functions that access sessionStorage; implement isSessionStorageAvailable to safely check typeof sessionStorage !== 'undefined' and export it (or keep module-private) so intent is clear and maintenance is simplified.apps/server-core/src/core/entities/client/web-client.ts (1)
31-45: ⚡ Quick winValidate that
appOriginsis not empty.The function constructs
redirect_uriby mapping overappOrigins. If the array is empty,redirect_uriwill be an empty string, which would break OAuth authorization flows. SincebuildWebClientAttributesis exported and could be called from other contexts, defensive validation is a best practice.🛡️ Suggested validation
export function buildWebClientAttributes( realm: Realm | { id: string }, appOrigins: string[], ): Partial<Client> { + if (appOrigins.length === 0) { + throw new Error('appOrigins cannot be empty when building web client attributes'); + } + return {🤖 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/core/entities/client/web-client.ts` around lines 31 - 45, The buildWebClientAttributes function does not validate appOrigins and will produce an empty redirect_uri if called with an empty array; add a defensive check at the start of buildWebClientAttributes to verify appOrigins is a non-empty array and throw a clear error (or return a controlled failure) if it's empty or not provided so callers cannot create a client with an invalid redirect_uri; update any tests or callers that assume empty arrays accordingly and reference buildWebClientAttributes and the redirect_uri construction to locate the change.apps/server-core/test/unit/config/index.spec.ts (1)
14-38: ⚡ Quick winType casting bypasses type safety in tests.
The test objects use
as anytype casting (lines 19, 31), which disables TypeScript's type checking and could hide type errors.Consider using the proper Pick type instead:
♻️ Suggested type-safe alternative
it('should derive the origin from publicUrl, stripping any path', () => { const origins = getAppOrigins({ publicUrl: 'https://auth.example.com/sub/path', additionalDomains: [], - } as any); + } satisfies Pick<Config, 'publicUrl' | 'additionalDomains'>); expect(origins).toEqual(['https://auth.example.com']); }); it('should merge publicUrl with additionalDomains and dedupe by origin', () => { const origins = getAppOrigins({ publicUrl: 'https://auth.example.com', additionalDomains: [ 'https://auth.example.com/ignored-path', 'http://localhost:3000', ], - } as any); + } satisfies Pick<Config, 'publicUrl' | 'additionalDomains'>); expect(origins).toEqual([ 'https://auth.example.com', 'http://localhost:3000', ]); });Note:
satisfieswas introduced in TypeScript 4.9 and provides type checking while preserving the literal type.🤖 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/test/unit/config/index.spec.ts` around lines 14 - 38, The tests currently use unsafe type casts (`as any`) when calling getAppOrigins; replace those casts with a type-safe fixture such as using Pick or the `satisfies` operator to match the production config shape expected by getAppOrigins (e.g., create objects typed as Pick<AppConfig,'publicUrl'|'additionalDomains'> or use `... satisfies AppConfig`), update both test cases that construct the config input for getAppOrigins to use the typed object instead of `as any`, and ensure imports or type names (AppConfig, getAppOrigins) are referenced correctly so TypeScript checks the test inputs without losing literal types.
🤖 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 `@apps/server-core/src/app/modules/config/normalize.ts`:
- Around line 41-51: The code currently seeds devOrigin
('http://localhost:3000') whenever env !== EnvironmentName.PRODUCTION which also
affects TEST; update the behavior to match intent by either (A) changing the
comment above the block to say "In non-production..." to reflect the current
condition, or (B) narrow the runtime check to env ===
EnvironmentName.DEVELOPMENT if seeding should be development-only; modify the
block that touches parsed.additionalDomains / additionalDomains and the env
check (EnvironmentName) accordingly so the comment and condition are consistent.
In
`@packages/client-web-kit/src/components/workflows/authorize/AuthorizeForm.vue`:
- Around line 104-115: The auto-consent flow calls authorize() from onMounted
when autoConsent (computed from props.client.built_in) is true but currently
swallows failures and leaves the spinner running; add an error state (e.g., a
ref authError or authFailed) and ensure authorize() sets that state and clears
any loading flag in its catch block (where the TODO is), and also call the
existing toast/notification helper or emit an error event there; update the
template conditional rendering to show a fallback error message and the consent
UI (or a retry button) when authError is set so auto-consent failures surface to
the user instead of freezing the spinner.
---
Nitpick comments:
In `@apps/server-core/src/core/entities/client/web-client.ts`:
- Around line 31-45: The buildWebClientAttributes function does not validate
appOrigins and will produce an empty redirect_uri if called with an empty array;
add a defensive check at the start of buildWebClientAttributes to verify
appOrigins is a non-empty array and throw a clear error (or return a controlled
failure) if it's empty or not provided so callers cannot create a client with an
invalid redirect_uri; update any tests or callers that assume empty arrays
accordingly and reference buildWebClientAttributes and the redirect_uri
construction to locate the change.
In `@apps/server-core/test/unit/config/index.spec.ts`:
- Around line 14-38: The tests currently use unsafe type casts (`as any`) when
calling getAppOrigins; replace those casts with a type-safe fixture such as
using Pick or the `satisfies` operator to match the production config shape
expected by getAppOrigins (e.g., create objects typed as
Pick<AppConfig,'publicUrl'|'additionalDomains'> or use `... satisfies
AppConfig`), update both test cases that construct the config input for
getAppOrigins to use the typed object instead of `as any`, and ensure imports or
type names (AppConfig, getAppOrigins) are referenced correctly so TypeScript
checks the test inputs without losing literal types.
In `@packages/client-web-kit/src/core/oauth2/authorization-request.ts`:
- Around line 26-28: Extract the repeated guard into a small helper named
isSessionStorageAvailable(): boolean in authorization-request.ts and replace the
three occurrences of if (typeof sessionStorage === 'undefined') { return; } with
if (!isSessionStorageAvailable()) { return; } (or guard-return as appropriate)
inside the functions that access sessionStorage; implement
isSessionStorageAvailable to safely check typeof sessionStorage !== 'undefined'
and export it (or keep module-private) so intent is clear and maintenance is
simplified.
🪄 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
Run ID: 85d731c7-e4b0-45d9-beae-7341f7461aa9
📒 Files selected for processing (38)
.agents/architecture.mdapps/client-web/pages/login.vueapps/client-web/pages/login/callback.vueapps/client-web/pages/login/index.vueapps/server-core/src/adapters/http/middleware/built-in/cors.tsapps/server-core/src/app/modules/config/constants.tsapps/server-core/src/app/modules/config/index.tsapps/server-core/src/app/modules/config/normalize.tsapps/server-core/src/app/modules/config/origins.tsapps/server-core/src/app/modules/config/parse.tsapps/server-core/src/app/modules/config/read/env.tsapps/server-core/src/app/modules/config/types.tsapps/server-core/src/app/modules/http/modules/controller.tsapps/server-core/src/app/modules/http/modules/middleware.tsapps/server-core/src/app/modules/provisioning/module.tsapps/server-core/src/core/entities/client/index.tsapps/server-core/src/core/entities/client/service.tsapps/server-core/src/core/entities/client/types.tsapps/server-core/src/core/entities/client/web-client.tsapps/server-core/src/core/entities/realm/service.tsapps/server-core/test/unit/config/index.spec.tsapps/server-core/test/unit/core/entities/client/service.spec.tsapps/server-core/test/unit/core/entities/client/web-client.spec.tsapps/server-core/test/unit/core/entities/realm/service.spec.tsdocs/src/guide/deployment/configuration-client-web.mddocs/src/guide/deployment/configuration-server-core.mddocs/src/guide/deployment/provisioning.mdpackages/client-web-kit/src/components/entities/realm/ARealmGrid.vuepackages/client-web-kit/src/components/entities/realm/index.tspackages/client-web-kit/src/components/workflows/authorize/AuthorizeForm.vuepackages/client-web-kit/src/core/index.tspackages/client-web-kit/src/core/oauth2/authorization-request.tspackages/client-web-kit/src/core/oauth2/index.tspackages/client-web-kit/src/core/oauth2/pkce.tspackages/client-web-kit/src/core/store/create.tspackages/client-web-nuxt/src/runtime/helpers/routing-interceptor.tspackages/core-kit/src/domains/client/constants.tspackages/core-kit/src/domains/client/index.ts
💤 Files with no reviewable changes (1)
- apps/client-web/pages/login.vue
- log+swallow web client provisioning failures on realm create so realm creation stays atomic from the caller's perspective - parse routing-interceptor redirect target via URL so query/hash survive and any host is discarded (no open redirect); strip code/state on the failure path to prevent a consumed-code reload loop - fall back from the auto-consent spinner to the manual consent UI when confirm() fails, giving the user a retry path - clarify dev-origin seeding comment to cover test env
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@apps/server-core/src/core/entities/realm/service.ts`:
- Around line 147-163: Add a unit test for RealmService.create that simulates
webClientProvisioner.ensureForRealm throwing so we verify create still resolves
and the realm is persisted: in the existing realm service spec, stub/mocking the
service instance's webClientProvisioner.ensureForRealm to reject/throw, call
RealmService.create(...) and assert the promise resolves (does not reject),
assert the provisioner.ensureForRealm was invoked for the created entity, and
assert the realm was saved (e.g., query the repository or check the returned
entity has an id/persisted marker). Ensure the test cleans up mocks and does not
rely on the success path of ensureForRealm.
🪄 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
Run ID: d5197355-6ada-4264-a269-f4c26aab0ff0
📒 Files selected for processing (4)
apps/server-core/src/app/modules/config/normalize.tsapps/server-core/src/core/entities/realm/service.tspackages/client-web-kit/src/components/workflows/authorize/AuthorizeForm.vuepackages/client-web-nuxt/src/runtime/helpers/routing-interceptor.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- apps/server-core/src/app/modules/config/normalize.ts
- packages/client-web-nuxt/src/runtime/helpers/routing-interceptor.ts
- packages/client-web-kit/src/components/workflows/authorize/AuthorizeForm.vue
Redesign ARealmGrid as a modern realm picker (search-on-threshold, single-realm auto-select, gradient avatars, animated hover border, skeleton loading) and wrap the login page in an aurora-backed hero with localized title/subtitle. Adds SEARCH/NO_RESULTS common keys and LOGIN_TITLE/LOGIN_SUBTITLE app keys across en/de/fr/es.
Complete the realm-selection login arc: the backend-served /authorize page becomes the hub for password login, IdP login, registration and password recovery - fully functional in headless deployments. - status: GET / exposes feature flags (registration, passwordRecovery, emailVerification); typed StatusResponse + client.status.get() - client-web-kit: new workflow forms ARegisterForm (embeds AActivateForm on email verification), APasswordForgotForm, APasswordResetForm; ALogin renamed to ALoginForm (deprecated alias kept) with VCLink-based register/password-forgot links; AAuthShell aurora card replaces the legacy hardcoded consent styling; AColorModeSwitcher added; LanguageSwitcherDropdown renamed to ALanguageSwitcherDropdown (deprecated alias kept) - server-core: GET /register, /activate, /password-forgot and /password-reset serve SSR pages via a shared renderUIPage helper; same-origin redirect continuity with open-redirect guard; activation/reset mails carry deep links (publicUrl); embedded UI gains color-mode + language gadgets with vc-* cookie persistence (@vuecs/locale) and self-hosted Nunito/Asap webfonts - client-web: chrome-less auth layout for login/callback, refined realm-grid tiles (no avatars, slug subtitle), orbit-mark hero SVG, "Sign in" copy across locales - i18n: workflow vocabulary authored in en/de/fr/es; SWITCH_TO_* keys moved from the app-only APP namespace to COMMON - fix: ALanguageSwitcherDropdown async setup prevented hydration outside a Suspense boundary (dropdown dead on backend pages); IdP boxes overflowing the auth card now wrap
There was a problem hiding this comment.
Actionable comments posted: 9
🤖 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 `@apps/client-web/layouts/auth.vue`:
- Line 48: The layout currently renders the page directly via <NuxtPage /> which
causes nested page lifecycle issues; replace the <NuxtPage /> usage in
apps/client-web/layouts/auth.vue with the layout slot (<slot />) so Nuxt injects
routed page content into the layout; locate the occurrence of <NuxtPage /> in
the auth.vue template and swap it for a plain <slot /> (preserving any
surrounding container/attributes) to restore correct layout/page composition.
In `@apps/server-core/src/adapters/http/ui/render.ts`:
- Around line 89-98: sanitizeRelativeRedirect currently only checks raw string
prefixes and can be bypassed by percent-encoded separators or control chars;
update sanitizeRelativeRedirect to first safely normalize/decode the input
(e.g., attempt a single decodeURIComponent with try/catch) and then reject any
inputs that contain encoded or decoded separator/control patterns
(percent-encodings for '/' and '\' like %2f/%5c in any case, sequences that
normalize to '//' or '/\' or that do not start with a single '/' after decoding,
and control chars like CR/LF or their encodings such as %0a/%0d). Ensure you
still return undefined for non-strings or empty strings and return the original
input only when the decoded/validated value is a simple relative path beginning
with exactly one '/' and contains no disallowed characters or encoded
separators.
In `@apps/server-core/ui/src/cookie.ts`:
- Around line 16-17: The cookie lookup builds a RegExp from the raw cookie name
which allows regex metacharacters in name to break or throw; escape the cookie
name before interpolation. Add or use an escapeRegExp helper (e.g.,
escapeRegExp) and call it on the name variable, then construct the RegExp with
the escaped value in the document.cookie.match(...) expression (the line that
currently uses new RegExp(`(?:^|;\\s*)${name}=([^;]+)`)). Ensure the helper
replaces all regex-special characters with escaped versions so cookie keys with
symbols are safely matched.
In `@apps/server-core/ui/src/pages/activate.vue`:
- Around line 44-45: The activation form is gated only by
data.features.registration which can display a dead-end when activation tokens
are only issued if email verification is enabled; update the visibility check
for the component that receives :token="data.token" to require both registration
and the email-verification feature (e.g., check data.features.registration &&
(data.features.emailVerification || data.features.email_verification)), so the
activation form is only shown when tokens will actually be issued.
- Around line 54-59: The anchor binds untrusted data.redirect directly to href,
allowing unsafe schemes (e.g., javascript:) or off-origin navigation; update the
rendering to validate and sanitize data.redirect before binding: implement a
check in the component (e.g., a computed property or method used by the
template) that rejects or normalizes values that are not a safe relative path
(e.g., starts with '/' and does not start with '//' or contain newlines) or that
are not on an explicit allowlist of origins/paths, and only return the sanitized
value for use in the template (leave translations.backToLogin untouched); if
validation fails, render a safe default (such as '/login' or no anchor) instead
of the raw data.redirect.
In `@packages/client-web-kit/src/components/entities/realm/ARealmGrid.vue`:
- Around line 78-81: The current auto-select logic (props.autoSelectSingle)
immediately sets redirecting.value = true and emits('select', items.value[0])
with no recovery if navigation fails; modify the ARealmGrid component to add a
fallback path: start a timeout when auto-select triggers that will reset
redirecting.value and emit an 'error' or 'autoSelectTimeout' event if no
confirmation/clear happens in e.g. 5–10s, and ensure the component clears that
timeout when a successful navigation/confirmation path is detected or when the
parent calls a new reset method/prop; reference the existing symbols
redirecting.value, props.autoSelectSingle, items.value and emit('select', ...)
to locate where to add the timer, cancellation logic, and the new emit('error'
or 'autoSelectTimeout') so parents can handle failures and reset UI.
In
`@packages/client-web-kit/src/components/workflows/password/PasswordResetForm.vue`:
- Around line 60-64: The reactive form object copies props.token once, causing
stale tokens when the parent updates props.token; add a watcher to keep
form.token in sync with prop changes (watch(() => props.token, v => form.token =
v)) and ensure vue's watch is imported; update PasswordResetForm.vue to set
form.token initially as now but also update it inside the watch so submissions
always use the current props.token.
In `@packages/client-web-kit/src/components/workflows/register/ActivateForm.vue`:
- Line 53: The reactive form object is initialized with props.token but not
updated when the token prop changes, so add a watcher to keep form.token in sync
with the prop; locate the reactive form declaration (const form = reactive({
token: props.token })) in ActivateForm.vue and add a watch on props.token (or a
watchEffect) that assigns the new prop value to form.token whenever props.token
changes so the component won't submit a stale token.
In `@packages/client-web-kit/src/components/workflows/register/RegisterForm.vue`:
- Around line 166-168: RegisterForm currently listens to ActivateForm and
re-emits only the 'done' event, dropping 'failed' so activation errors don't
propagate; update the RegisterForm component where ActivateForm is used (the
<ActivateForm ... /> block) to forward its 'failed' event as well by adding an
`@failed` handler that re-emits 'failed' (i.e., `@failed`="$emit('failed', $event)")
alongside the existing `@done` emission so parent listeners on RegisterForm
receive activation failures.
🪄 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
Run ID: 67bcdfac-4dd9-48d8-8253-bff1607cb7bc
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (76)
.agents/architecture.md.agents/structure.mdapps/client-web/components/header.vueapps/client-web/components/svg/LoginHeroSVG.vueapps/client-web/layouts/auth.vueapps/client-web/pages/login/callback.vueapps/client-web/pages/login/index.vueapps/server-core/package.jsonapps/server-core/src/adapters/http/controllers/workflows/activate/module.tsapps/server-core/src/adapters/http/controllers/workflows/authorize/module.tsapps/server-core/src/adapters/http/controllers/workflows/authorize/types.tsapps/server-core/src/adapters/http/controllers/workflows/password-forgot/module.tsapps/server-core/src/adapters/http/controllers/workflows/password-reset/module.tsapps/server-core/src/adapters/http/controllers/workflows/register/module.tsapps/server-core/src/adapters/http/controllers/workflows/status/module.tsapps/server-core/src/adapters/http/ui/index.tsapps/server-core/src/adapters/http/ui/render.tsapps/server-core/src/adapters/http/ui/types.tsapps/server-core/src/app/modules/http/modules/controller.tsapps/server-core/src/core/identity/password-recovery/service.tsapps/server-core/src/core/identity/password-recovery/types.tsapps/server-core/src/core/identity/registration/service.tsapps/server-core/src/core/identity/registration/types.tsapps/server-core/test/unit/http/controllers/workflows/status.spec.tsapps/server-core/ui/src/App.vueapps/server-core/ui/src/app.tsapps/server-core/ui/src/color-mode.tsapps/server-core/ui/src/cookie.tsapps/server-core/ui/src/pages/activate.vueapps/server-core/ui/src/pages/authorize.vueapps/server-core/ui/src/pages/password-forgot.vueapps/server-core/ui/src/pages/password-reset.vueapps/server-core/ui/src/pages/register.vueapps/server-core/ui/src/tailwind.csspackages/client-web-kit/package.jsonpackages/client-web-kit/src/components/entities/realm/ARealmGrid.vuepackages/client-web-kit/src/components/utility/AAuthShell.vuepackages/client-web-kit/src/components/utility/AColorModeSwitcher.vuepackages/client-web-kit/src/components/utility/ALanguageSwitcherDropdown.tspackages/client-web-kit/src/components/utility/index.tspackages/client-web-kit/src/components/workflows/authorize/Authorize.vuepackages/client-web-kit/src/components/workflows/index.tspackages/client-web-kit/src/components/workflows/login/LoginForm.vuepackages/client-web-kit/src/components/workflows/login/index.tspackages/client-web-kit/src/components/workflows/password/PasswordForgotForm.vuepackages/client-web-kit/src/components/workflows/password/PasswordResetForm.vuepackages/client-web-kit/src/components/workflows/password/index.tspackages/client-web-kit/src/components/workflows/register/ActivateForm.vuepackages/client-web-kit/src/components/workflows/register/RegisterForm.vuepackages/client-web-kit/src/components/workflows/register/index.tspackages/core-http-kit/src/client/module.tspackages/core-http-kit/src/domains/workflows/index.tspackages/core-http-kit/src/domains/workflows/status/index.tspackages/core-http-kit/src/domains/workflows/status/module.tspackages/core-http-kit/src/domains/workflows/status/types.tspackages/i18n/src/catalogs/de/action.tspackages/i18n/src/catalogs/de/app.tspackages/i18n/src/catalogs/de/client.tspackages/i18n/src/catalogs/de/common.tspackages/i18n/src/catalogs/de/field.tspackages/i18n/src/catalogs/en/action.tspackages/i18n/src/catalogs/en/app.tspackages/i18n/src/catalogs/en/client.tspackages/i18n/src/catalogs/en/common.tspackages/i18n/src/catalogs/en/field.tspackages/i18n/src/catalogs/es/action.tspackages/i18n/src/catalogs/es/app.tspackages/i18n/src/catalogs/es/client.tspackages/i18n/src/catalogs/es/common.tspackages/i18n/src/catalogs/es/field.tspackages/i18n/src/catalogs/fr/action.tspackages/i18n/src/catalogs/fr/app.tspackages/i18n/src/catalogs/fr/client.tspackages/i18n/src/catalogs/fr/common.tspackages/i18n/src/catalogs/fr/field.tspackages/i18n/src/constants.ts
✅ Files skipped from review due to trivial changes (19)
- packages/client-web-kit/src/components/utility/AColorModeSwitcher.vue
- packages/i18n/src/catalogs/es/field.ts
- .agents/structure.md
- packages/core-http-kit/src/domains/workflows/status/types.ts
- packages/core-http-kit/src/domains/workflows/status/index.ts
- apps/server-core/src/core/identity/password-recovery/types.ts
- packages/i18n/src/catalogs/en/common.ts
- apps/server-core/src/adapters/http/ui/types.ts
- packages/client-web-kit/src/components/workflows/password/index.ts
- packages/i18n/src/catalogs/en/client.ts
- packages/core-http-kit/src/domains/workflows/index.ts
- apps/server-core/ui/src/tailwind.css
- apps/server-core/ui/src/color-mode.ts
- packages/client-web-kit/src/components/workflows/login/index.ts
- apps/server-core/src/core/identity/registration/types.ts
- packages/i18n/src/catalogs/fr/field.ts
- packages/client-web-kit/src/components/workflows/register/index.ts
- packages/i18n/src/catalogs/en/field.ts
- packages/client-web-kit/package.json
🚧 Files skipped from review as they are similar to previous changes (2)
- apps/client-web/pages/login/callback.vue
- apps/client-web/pages/login/index.vue
| <ALanguageSwitcherDropdown link-class-extra="auth-layout-gadget" /> | ||
| </div> | ||
|
|
||
| <NuxtPage /> |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
In Nuxt 4 layouts, is the supported way to render page content instead of, and what are the behavioral differences?
💡 Result:
In Nuxt 4, the <slot /> component is the correct and supported way to render page content within a layout file [1][2]. The <NuxtPage /> component serves a different purpose and is not a replacement for <slot /> inside layouts [3][4]. The behavioral differences and intended usage are as follows: 1. Layout Files (Use <slot />): Layouts are designed as wrappers for your pages [5]. Within a layout file (e.g., app/layouts/default.vue), you use <slot /> to define where the page content should be injected [1][2]. This follows standard Vue slot patterns, allowing you to create flexible layouts with multiple slots (e.g., named slots for headers or sidebars) [1][6]. 2. Application Entry (Use <NuxtPage />): The <NuxtPage /> component is used at the top level of your application (typically in app.vue) to render the actual pages found in the app/pages/ directory [3][5]. It acts as a placeholder that Nuxt automatically populates based on the current route [3]. Summary of roles: - Use in app.vue (or your root component) to render the active page [3][5]. - Use in layout files to define the insertion point for the page content passed through the layout [1][2]. If you were to mistakenly use inside a layout file, it would not function as the slot for that layout's content; rather, it would attempt to render a secondary, nested page view, which is likely not the desired behavior for standard page-layout composition [4].
Citations:
- 1: https://nuxt.com/docs/4.x/guide/directory-structure/layouts
- 2: https://nuxt.com/docs/4.x/directory-structure/app/layouts
- 3: https://nuxt.com/docs/4.x/api/components/nuxt-page
- 4: https://stackoverflow.com/questions/72659470/nuxtpage-vs-slot-for-nuxt3
- 5: https://nuxt.com/docs/4.x/getting-started/views
- 6: https://nuxt.com/docs/4.x/api/components/nuxt-layout
🏁 Script executed:
#!/bin/bash
set -euo pipefail
ls -la
sed -n '1,120p' apps/client-web/layouts/auth.vue | nl -ba | sed -n '35,80p'Repository: authup/authup
Length of output: 2824
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Show the relevant portion around the referenced line in apps/client-web/layouts/auth.vue
if [ ! -f apps/client-web/layouts/auth.vue ]; then
echo "Missing file: apps/client-web/layouts/auth.vue"
exit 1
fi
sed -n '1,140p' apps/client-web/layouts/auth.vue | nl -ba | sed -n '35,90p'Repository: authup/authup
Length of output: 100
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1,160p' apps/client-web/layouts/auth.vue | nl -ba | sed -n '35,95p'Repository: authup/authup
Length of output: 100
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1,180p' apps/client-web/layouts/auth.vue | nl -ba | sed -n '35,105p'Repository: authup/authup
Length of output: 100
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="apps/client-web/layouts/auth.vue"
if [ ! -f "$FILE" ]; then
echo "Missing file: $FILE"
exit 1
fi
# Print lines around the referenced line (48)
start=35
end=70
echo "---- $FILE lines $start-$end ----"
sed -n "${start},${end}p" "$FILE" | cat -n
echo "---- end ----"Repository: authup/authup
Length of output: 1229
🏁 Script executed:
#!/bin/bash
set -euo pipefail
FILE="apps/client-web/layouts/auth.vue"
if [ ! -f "$FILE" ]; then
echo "Missing file: $FILE"
exit 1
fi
start=35
end=70
echo "---- $FILE lines $start-$end ----"
sed -n "${start},${end}p" "$FILE" | cat -n
echo "---- end ----"Repository: authup/authup
Length of output: 1229
Use layout slot content (<slot />) instead of <NuxtPage /> in apps/client-web/layouts/auth.vue.
This layout is expected to render the current page via <slot />; placing <NuxtPage /> inside the layout can lead to incorrect/nested page lifecycle behavior instead of Nuxt injecting the routed page content into the layout.
Suggested fix
- <NuxtPage />
+ <slot />📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| <NuxtPage /> | |
| <slot /> |
🤖 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/client-web/layouts/auth.vue` at line 48, The layout currently renders
the page directly via <NuxtPage /> which causes nested page lifecycle issues;
replace the <NuxtPage /> usage in apps/client-web/layouts/auth.vue with the
layout slot (<slot />) so Nuxt injects routed page content into the layout;
locate the occurrence of <NuxtPage /> in the auth.vue template and swap it for a
plain <slot /> (preserving any surrounding container/attributes) to restore
correct layout/page composition.
| <div | ||
| v-if="data.redirect" | ||
| class="text-center" | ||
| > | ||
| <a :href="data.redirect">{{ translations.backToLogin }}</a> | ||
| </div> |
There was a problem hiding this comment.
Sanitize data.redirect before binding it to href.
Rendering unvalidated redirect strings as anchors can expose unsafe schemes (for example javascript:) or unintended off-origin navigation. Restrict this to a safe relative path or strict allowlist before rendering.
Suggested patch
<script lang="ts">
import { AActivateForm, AAuthShell, useTranslations } from '`@authup/client-web-kit`';
import type { StatusResponseFeatures } from '`@authup/core-http-kit`';
import { TranslatorTranslationClientKey, TranslatorTranslationNamespace } from '`@authup/i18n`';
-import { defineComponent } from 'vue';
+import { computed, defineComponent } from 'vue';
import { injectPayload } from '../di';
export default defineComponent({
components: { AActivateForm, AAuthShell },
setup() {
@@
+ const safeRedirect = computed(() => {
+ const value = payload.data?.redirect;
+ if (!value) {
+ return undefined;
+ }
+
+ // Allow only same-origin relative paths.
+ if (value.startsWith('/') && !value.startsWith('//')) {
+ return value;
+ }
+
+ return undefined;
+ });
+
return {
data: payload.data,
+ safeRedirect,
translations,
};
},
});
</script>
@@
- <div
- v-if="data.redirect"
+ <div
+ v-if="safeRedirect"
class="text-center"
>
- <a :href="data.redirect">{{ translations.backToLogin }}</a>
+ <a :href="safeRedirect">{{ translations.backToLogin }}</a>
</div>🤖 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/ui/src/pages/activate.vue` around lines 54 - 59, The anchor
binds untrusted data.redirect directly to href, allowing unsafe schemes (e.g.,
javascript:) or off-origin navigation; update the rendering to validate and
sanitize data.redirect before binding: implement a check in the component (e.g.,
a computed property or method used by the template) that rejects or normalizes
values that are not a safe relative path (e.g., starts with '/' and does not
start with '//' or contain newlines) or that are not on an explicit allowlist of
origins/paths, and only return the sanitized value for use in the template
(leave translations.backToLogin untouched); if validation fails, render a safe
default (such as '/login' or no anchor) instead of the raw data.redirect.
|
@coderabbitai pause |
✅ Action performedReviews paused. |
Address correctness issues found in review of the auth workflow branch: - ui: escape the SSR hydration payload (</script>, U+2028/2029) before inlining into <script> — workflow pages reflect raw token/realm_id query params, so this was a reflected-XSS vector - oauth2: consent confirm forwards the full code request (code_challenge, code_challenge_method, nonce, realm_id) so POST /authorize no longer rejects public clients with invalid_request - oauth2: skip the authorization-code exchange during SSR and render /login/callback client-only; running it server-side exchanged without the PKCE verifier and burned the single-use code for the public client - password-recovery: reset deep link carries realm_id, so non-master realm users can complete the reset - config: copy parsed.additionalDomains instead of mutating it in place - login: preserve sibling query params across the login round-trip
Review-comment fixes and plan-024 §2 duplication collapse in the auth workflow components: - RegisterForm forwards ActivateForm `failed` events (were dropped) - ActivateForm/PasswordResetForm sync form.token when the prop changes - ARealmGrid exposes reset() so the login page can recover the auto-select skeleton when the redirect glue fails - forms route submit through the existing wrapFnWithBusyState helper instead of hand-rolled busy guards - pkce reuses @authup/kit base64URLEncode (strFromBytes is the only local step) - shared AAuthBackLink + AAuthGadgets kit components replace the back-link and color-mode/language cluster duplicated across the forms and both auth surfaces (client-web layout + embedded SSR app)
Plan-024 §3/§4 and remaining review comments for the backend auth pages: - move sanitizeRelativeRedirect to adapters/http/request/helpers and harden it against control chars, backslash and percent-encoded separator bypasses; add a spec table (the SSR pages are otherwise untestable) - single serveWorkflowPage() helper backs the four workflow GET routes; controllers shrink to thin POST adapters - StatusController reads package.json version once and consumes the unified StatusResponseFeatures shape (one feature-flags object) - renderUIPage caches the immutable dist shell/manifest/render across requests and injects the <html> attrs by pattern, not exact string - WebClientProvisioner dirty-checks before the merge save (no redundant UPDATE per realm on steady-state boot) - locale watchers are client-only (no-op on the SSR render path); toAuthupLocale promoted to @authup/i18n matchLocale() - activate page gates on emailVerification (activation tokens only exist then); escape the cookie name regex; realm create test for the swallowed provisioner failure
IdentityRoleProvider.reduceByIdentityClient dropped every client-agnostic role (client_id null) when the token's identity carried a client_id, keeping only roles scoped to that exact client. The legacy client-web login used the password grant with no client, so the filter was a no-op and global/realm roles flowed through. The realm-selection login issues the token via the per-realm `web` client, which supplies a client_id — so the filter stripped every global/realm role, leaving introspection's permissions / realm_access.roles / global_access.roles empty for admin. Keep null-client (global/realm) roles in addition to roles scoped to the authenticating client.
Make locale handling consistent with color-mode/palette: @vuecs/locale is the source of truth (vc-locale cookie, auto-resolution, Config['locale']), the same way @vuecs/design's bindColorMode owns vc-color-mode. - ALanguageSwitcherDropdown writes vuecs via a new useLocaleControl() helper that prefers @vuecs/locale's useLocaleManager and falls back to the ilingo ref when vuecs-locale isn't installed (kit stays usable without it) - syncTranslatorLocaleFromManager() bridges vuecs resolved -> ilingo one-way; the previous two-way ilingo<->vuecs bridge is removed - client-web: drop the config.locale ilingo feed (the @vuecs/nuxt locale plugin, on by default, owns Config['locale']); new post plugin runs the one-way sync after it. client-web now persists locale like it already persists color-mode - server-core/ui: keep installLocale; replace the two-way bridge with the one-way sync - add @vuecs/locale to client-web-kit deps/peer
Replace the inline mail HTML in RegistrationService / PasswordRecoveryService
with an IMailTemplateRenderer port (core/mail). Services pass
{ template, params: { code, url? }, locale? }; the default MailTemplateRenderer
resolves localized copy (en/de/fr/es, BCP-47-narrowed with default fallback),
html-escapes interpolated values, and wraps the body in a small branded shell
(subject + html + text).
- decouples mail copy/markup from the workflow services
- localized + brandable in one place
- pure + injected, so mail content is now assertable via FakeMailClient
(adds core/mail/renderer.spec.ts)
There was a problem hiding this comment.
Actionable comments posted: 4
♻️ Duplicate comments (2)
apps/client-web/layouts/auth.vue (1)
42-42:⚠️ Potential issue | 🔴 Critical | ⚡ Quick winUse
<slot />instead of<NuxtPage />in layout files.This layout must render page content via
<slot />to follow Nuxt's layout contract.<NuxtPage />is for the rootapp.vuecomponent, not layouts; using it here causes nested page lifecycle behavior instead of properly injecting the routed page content into the layout wrapper.🔧 Proposed fix
- <NuxtPage /> + <slot />🤖 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/client-web/layouts/auth.vue` at line 42, The layout currently renders routed content with the NuxtPage component (NuxtPage) which is incorrect for layout files; change the layout template to render the routed page via the default slot by replacing the NuxtPage usage with a <slot /> so the routed page is injected correctly into the layout wrapper and lifecycle behavior is preserved.apps/server-core/ui/src/pages/activate.vue (1)
58-63:⚠️ Potential issue | 🟠 Major | ⚡ Quick winSanitize
data.redirectbefore binding tohref.The
redirectvalue originates from query parameters (per the window.ts payload comment) and is rendered directly as an anchor href without client-side validation. This exposes the application to XSS via unsafe URL schemes (e.g.,javascript:,data:) or unintended off-origin navigation.Even if the backend's
serveWorkflowPagesanitizes the redirect, defense-in-depth requires client-side validation here. Restrict the rendered value to safe relative paths (starting with/but not//) or an explicit origin allowlist.🛡️ Proposed sanitization
<script lang="ts"> import { AActivateForm, AAuthShell, useTranslations } from '`@authup/client-web-kit`'; import type { StatusResponseFeatures } from '`@authup/core-http-kit`'; import { TranslatorTranslationClientKey, TranslatorTranslationNamespace } from '`@authup/i18n`'; -import { defineComponent } from 'vue'; +import { computed, defineComponent } from 'vue'; import { injectPayload } from '../di'; export default defineComponent({ components: { AActivateForm, AAuthShell }, setup() { const payload = injectPayload<{ features?: StatusResponseFeatures, token?: string, redirect?: string, }>(); const translations = useTranslations([ { namespace: TranslatorTranslationNamespace.CLIENT, key: TranslatorTranslationClientKey.WORKFLOW_DISABLED, }, { namespace: TranslatorTranslationNamespace.CLIENT, key: TranslatorTranslationClientKey.BACK_TO_LOGIN, }, ]); + const safeRedirect = computed(() => { + const value = payload.data?.redirect; + if (!value) { + return undefined; + } + // Allow only same-origin relative paths + if (value.startsWith('/') && !value.startsWith('//')) { + return value; + } + return undefined; + }); + return { data: payload.data, + safeRedirect, translations, }; }, }); </script> <template> <AAuthShell> <AActivateForm v-if="data.features && data.features.emailVerification" :token="data.token" /> <div v-else class="alert alert-warning" > {{ translations.workflowDisabled }} </div> <div - v-if="data.redirect" + v-if="safeRedirect" class="text-center" > - <a :href="data.redirect">{{ translations.backToLogin }}</a> + <a :href="safeRedirect">{{ translations.backToLogin }}</a> </div> </AAuthShell> </template>🤖 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/ui/src/pages/activate.vue` around lines 58 - 63, data.redirect is rendered directly into the anchor href in activate.vue, which can allow unsafe URL schemes; update the template logic (the binding around data.redirect) to validate and sanitize the redirect before binding: allow only safe relative paths that start with "/" but not "//", or match a configured origin allowlist (use window origin comparison), and fall back to a safe internal path (e.g., "/login") when validation fails; implement the validation in the component script (adjacent to where data is consumed from the window payload) and use the sanitized value in the template instead of data.redirect.
🧹 Nitpick comments (1)
apps/server-core/src/adapters/http/ui/render.ts (1)
87-90: ⚖️ Poor tradeoffRegex-based tag replacement discards existing attributes.
The regex replacement at line 90 completely replaces the
<html>tag, which means any attributes present in the source template (or added by Vite'stransformIndexHtmlin JIT mode) will be lost. While this may be intentional for the current use case, consider preserving or merging existing attributes if the template is expected to carry additional data attributes or other metadata.🤖 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/adapters/http/ui/render.ts` around lines 87 - 90, The current regex replacement on variable body (body.replace(/<html\b[^>]*>/i, `<html ${htmlAttrs}>`)) discards any existing <html> attributes; change it to capture the existing attribute string (e.g. using /<html\b([^>]*)>/i), parse or split that captured attrs and merge them with htmlAttrs (preserving existing keys and avoiding duplicates), then replace the tag using a replacer callback so the final <html ...> contains both original attributes and the new htmlAttrs; update the code around body and htmlAttrs (the replace call) to perform this merge rather than overwriting.
🤖 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 `@apps/server-core/src/adapters/http/request/helpers/redirect.ts`:
- Around line 25-28: The current check only tests the raw input for control
characters (using the regex against input) but misses percent-encoded controls
that decode into CR/LF; update the validation in the redirect helper so that
after decoding (using the same decode logic already in use for value) you also
run the control-character test on the decoded string (and handle decode errors
safely), returning undefined if the decoded value contains any control chars
(same /[\u0000-\u0020\u007f]/ check) to prevent header injection; reference the
existing variables input and value (the decoded value) in your change and ensure
you catch/deal with URI-decode errors.
In `@apps/server-core/src/core/mail/renderer.ts`:
- Around line 28-48: In renderHtmlShell, action.url is interpolated directly
into the href which can lead to XSS if the URL contains quotes or HTML-special
chars; fix by escaping the URL for HTML attribute context before injecting it
(e.g. call the same escapeHtml or a dedicated escapeAttribute function on
action.url) and use that escaped value in the href, keeping the existing
escapeHtml(action.label) for the link text.
In `@apps/server-core/test/unit/core/mail/renderer.spec.ts`:
- Around line 14-25: Add a unit test for renderer.render using
MailTemplateName.REGISTRATION_ACTIVATION that passes a malicious URL (e.g.
containing & and a quote plus onclick payload) as the url param and asserts the
produced mail.html does NOT contain the raw onclick payload and DOES contain
escaped entities (e.g. " and/or &) to verify url escaping; place the
test alongside the existing activation tests that already validate code escaping
so it exercises the renderer.render behavior referenced in renderer.ts.
In `@packages/client-web-kit/src/components/utility/AAuthBackLink.vue`:
- Around line 7-14: The template uses VCIcon but it is not imported or
registered; import VCIcon (the component used in the template) alongside VCLink
in the script and add it to the components option inside the defineComponent
call (e.g., components: { VCLink, VCIcon }) so VCIcon is available at runtime
when rendering AAuthBackLink.vue.
---
Duplicate comments:
In `@apps/client-web/layouts/auth.vue`:
- Line 42: The layout currently renders routed content with the NuxtPage
component (NuxtPage) which is incorrect for layout files; change the layout
template to render the routed page via the default slot by replacing the
NuxtPage usage with a <slot /> so the routed page is injected correctly into the
layout wrapper and lifecycle behavior is preserved.
In `@apps/server-core/ui/src/pages/activate.vue`:
- Around line 58-63: data.redirect is rendered directly into the anchor href in
activate.vue, which can allow unsafe URL schemes; update the template logic (the
binding around data.redirect) to validate and sanitize the redirect before
binding: allow only safe relative paths that start with "/" but not "//", or
match a configured origin allowlist (use window origin comparison), and fall
back to a safe internal path (e.g., "/login") when validation fails; implement
the validation in the component script (adjacent to where data is consumed from
the window payload) and use the sanitized value in the template instead of
data.redirect.
---
Nitpick comments:
In `@apps/server-core/src/adapters/http/ui/render.ts`:
- Around line 87-90: The current regex replacement on variable body
(body.replace(/<html\b[^>]*>/i, `<html ${htmlAttrs}>`)) discards any existing
<html> attributes; change it to capture the existing attribute string (e.g.
using /<html\b([^>]*)>/i), parse or split that captured attrs and merge them
with htmlAttrs (preserving existing keys and avoiding duplicates), then replace
the tag using a replacer callback so the final <html ...> contains both original
attributes and the new htmlAttrs; update the code around body and htmlAttrs (the
replace call) to perform this merge rather than overwriting.
🪄 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
Run ID: 3b0a4caa-30b9-4b6b-ac4c-d5dbc1f9b449
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (56)
.agents/architecture.md.agents/structure.mdapps/client-web/layouts/auth.vueapps/client-web/nuxt.config.tsapps/client-web/pages/login/index.vueapps/client-web/plugins/vuecs-locale.tsapps/client-web/plugins/vuecs.tsapps/server-core/src/adapters/http/controllers/workflows/activate/module.tsapps/server-core/src/adapters/http/controllers/workflows/password-forgot/module.tsapps/server-core/src/adapters/http/controllers/workflows/password-reset/module.tsapps/server-core/src/adapters/http/controllers/workflows/register/module.tsapps/server-core/src/adapters/http/controllers/workflows/status/module.tsapps/server-core/src/adapters/http/request/helpers/index.tsapps/server-core/src/adapters/http/request/helpers/redirect.tsapps/server-core/src/adapters/http/ui/index.tsapps/server-core/src/adapters/http/ui/render.tsapps/server-core/src/adapters/http/ui/serve.tsapps/server-core/src/app/modules/config/normalize.tsapps/server-core/src/app/modules/http/modules/controller.tsapps/server-core/src/core/entities/client/web-client.tsapps/server-core/src/core/identity/password-recovery/service.tsapps/server-core/src/core/identity/password-recovery/types.tsapps/server-core/src/core/identity/registration/service.tsapps/server-core/src/core/identity/registration/types.tsapps/server-core/src/core/identity/role/module.tsapps/server-core/src/core/mail/index.tsapps/server-core/src/core/mail/renderer.tsapps/server-core/src/core/mail/templates.tsapps/server-core/src/core/mail/types.tsapps/server-core/test/unit/adapters/http/request/redirect.spec.tsapps/server-core/test/unit/core/entities/realm/service.spec.tsapps/server-core/test/unit/core/identity/password-recovery/service.spec.tsapps/server-core/test/unit/core/identity/registration/service.spec.tsapps/server-core/test/unit/core/identity/role/module.spec.tsapps/server-core/test/unit/core/mail/renderer.spec.tsapps/server-core/ui/src/App.vueapps/server-core/ui/src/app.tsapps/server-core/ui/src/cookie.tsapps/server-core/ui/src/pages/activate.vueapps/server-core/ui/src/window.tspackages/client-web-kit/package.jsonpackages/client-web-kit/src/components/entities/realm/ARealmGrid.vuepackages/client-web-kit/src/components/utility/AAuthBackLink.vuepackages/client-web-kit/src/components/utility/AAuthGadgets.vuepackages/client-web-kit/src/components/utility/ALanguageSwitcherDropdown.tspackages/client-web-kit/src/components/utility/index.tspackages/client-web-kit/src/components/workflows/authorize/AuthorizeForm.vuepackages/client-web-kit/src/components/workflows/password/PasswordForgotForm.vuepackages/client-web-kit/src/components/workflows/password/PasswordResetForm.vuepackages/client-web-kit/src/components/workflows/register/ActivateForm.vuepackages/client-web-kit/src/components/workflows/register/RegisterForm.vuepackages/client-web-kit/src/core/oauth2/pkce.tspackages/client-web-kit/src/core/translator/index.tspackages/client-web-kit/src/core/translator/locale.tspackages/client-web-nuxt/src/runtime/helpers/routing-interceptor.tspackages/i18n/src/locales.ts
✅ Files skipped from review due to trivial changes (7)
- packages/client-web-kit/src/core/translator/index.ts
- apps/client-web/plugins/vuecs-locale.ts
- apps/server-core/src/core/mail/index.ts
- apps/server-core/src/adapters/http/request/helpers/index.ts
- apps/server-core/src/core/mail/templates.ts
- apps/server-core/src/core/identity/password-recovery/types.ts
- .agents/architecture.md
🚧 Files skipped from review as they are similar to previous changes (14)
- apps/server-core/src/adapters/http/ui/index.ts
- packages/client-web-kit/src/components/utility/index.ts
- apps/server-core/test/unit/core/entities/realm/service.spec.ts
- packages/client-web-kit/package.json
- apps/server-core/src/core/entities/client/web-client.ts
- apps/server-core/src/app/modules/config/normalize.ts
- packages/client-web-kit/src/components/workflows/register/RegisterForm.vue
- packages/client-web-nuxt/src/runtime/helpers/routing-interceptor.ts
- packages/client-web-kit/src/components/entities/realm/ARealmGrid.vue
- packages/client-web-kit/src/components/workflows/password/PasswordForgotForm.vue
- apps/server-core/src/app/modules/http/modules/controller.ts
- packages/client-web-kit/src/components/workflows/password/PasswordResetForm.vue
- apps/server-core/src/core/identity/registration/service.ts
- packages/client-web-kit/src/components/workflows/authorize/AuthorizeForm.vue
| <script lang="ts"> | ||
| import type { PropType } from 'vue'; | ||
| import { defineComponent } from 'vue'; | ||
| import type { LinkProperties } from '@vuecs/link'; | ||
| import { VCLink } from '@vuecs/link'; | ||
| import { TranslatorTranslationClientKey, TranslatorTranslationNamespace } from '@authup/i18n'; | ||
| import { useTranslations } from '../../core'; | ||
|
|
There was a problem hiding this comment.
Missing import for VCIcon component.
The template uses VCIcon at Line 42, but the component is never imported in the script section. This will cause a runtime error when the component tries to render.
🔧 Proposed fix
import type { PropType } from 'vue';
import { defineComponent } from 'vue';
import type { LinkProperties } from '`@vuecs/link`';
-import { VCLink } from '`@vuecs/link`';
+import { VCLink, VCIcon } from '`@vuecs/link`';
import { TranslatorTranslationClientKey, TranslatorTranslationNamespace } from '`@authup/i18n`';
import { useTranslations } from '../../core';and register the component:
export default defineComponent({
- components: { VCLink },
+ components: { VCLink, VCIcon },
props: { link: { type: Object as PropType<LinkProperties> } },🤖 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 `@packages/client-web-kit/src/components/utility/AAuthBackLink.vue` around
lines 7 - 14, The template uses VCIcon but it is not imported or registered;
import VCIcon (the component used in the template) alongside VCLink in the
script and add it to the components option inside the defineComponent call
(e.g., components: { VCLink, VCIcon }) so VCIcon is available at runtime when
rendering AAuthBackLink.vue.
- sanitizeRelativeRedirect: also reject control chars in the decoded form so a percent-encoded CRLF (%0a/%0d) can't smuggle a header-injection vector past the raw-input check; keep accepting a legit encoded space (%20) by excluding 0x20 from the decoded check - MailTemplateRenderer: html-escape the action url before the href attribute (defense-in-depth — values are internal today, but interpolation must treat them as untrusted) - tests for both (encoded CR/LF rejection; url attribute-breakout escape)
The SSR pass and first hydration frame run before onMounted's load(), so the grid painted the "no results" branch with ilingo's unresolved namespace.key fallback (authupCommon.noResults) instead of the loading skeleton. Track a loaded flag and show the skeleton until the first load settles.
Summary
This branch turns the login entrypoint into a per-realm flow and makes server-core fully self-sufficient for every auth workflow (headless deployments included).
Per-realm
webclient + realm-selection loginwebfor every realm — at startup (incl. pre-existing realms) and on runtime realm creation. Public (is_confidential: false, PKCE required),built_in,scope: global openid, one<origin>/**redirect entry per trusted app origin. No migration — provisioning is idempotent (MERGE, guarded onbuilt_in) and reconciles on every startup./loginis now a Keycloak-style realm chooser (single realm auto-selects; client-side search above 8 realms). Selecting a realm runs authorization-code + PKCE againstclient_id=web&realm_id=<id>; the global routing interceptor verifiesstateand exchanges the code.built_inclients auto-consent in the SSR/authorizeUI (with fallback to the manual Allow/Deny form if the auto-submit fails).web/systemare reserved client names; the validator stripsbuilt_inso no API caller can self-assign it.ADDITIONAL_DOMAINSconfig extends the trusted app origins; this set drives both thewebclient's redirect allowlist and the CORS origin allowlist.Backend-served auth workflow UI + status endpoint
/register,/activate,/password-forgot,/password-resetnow serve SSR pages from the embedded UI (GET), whilePOSTon the same paths stays the JSON API. Pages render a localized "disabled" notice instead of 404 when a workflow is off (stale mail links shouldn't dead-end).GET /→{ version, date, features: { registration, passwordRecovery, emailVerification } }(StatusResponseincore-http-kit,client.status.get()); the same flags ride the SSR hydration payload.ALoginForm,ARegisterForm,AActivateForm,APasswordForgotForm,APasswordResetForm) + sharedAAuthShellchrome; client-web auth pages use a dedicated chrome-lessauthlayout.redirectparam so "back to login" restores the original/authorizerequest;sanitizeRelativeRedirect()rejects absolute / protocol-relative URLs (open-redirect guard).Mail-template renderer
IMailTemplateRendererport: localized copy (en/de/fr/es, BCP-47-narrowed), html-escaped interpolation, branded shell, multipart (html + text).publicUrlis set, mails deep-link to the SSR pages (/activate?token=…,/password-reset?token=…&realm_id=…); the raw code stays in the body for copy/paste, no PII in URLs.Locale ownership refactor
@vuecs/localeis now the source of truth for the UI locale (cookie-backedvc-locale, browser auto-resolve,<html lang>sync); ilingo follows one-way viasyncTranslatorLocaleFromManager. The kit's language switcher works with or without vuecs-locale installed.Fixes & hardening
CORS previously reflected all origins; it is now restricted to
publicUrl+additionalDomains. In production, if client-web is served from a different origin than the API'sPUBLIC_URL, you must add that origin toADDITIONAL_DOMAINSor both CORS and the login redirect (<origin>/**) will reject it. In non-production,http://localhost:3000is seeded automatically.Security: the
webclient isbuilt_in+globalscope, so any allowlisted origin can obtain a full-permission user token after login — only list origins you control.Audit notes (non-blocking)
Verified end-to-end:
/authorizeverifier resolves the per-realmwebclient viafindOneByIdOrName(client_id, realm_id);GET /realmsis unauthenticated so the logged-out realm grid loads;<origin>/**matches/login/callback; token-exchange param shapes match. Known minor smells left as-is:ARealmGridcaps at 100 realms (alphabetical; client-side search mitigates, no paging).exchangeAuthorizationCodedoesn't emitLOGGED_IN(no current subscribers; latent).Test plan
npm run test --workspace=apps/server-coregreen/loginrealm selection → consent auto-submit → token exchange → land on home, in both dev and a prod-like split-origin setupADDITIONAL_DOMAINScorrectly gates CORS + redirect in productionSummary by CodeRabbit
New Features
Locale & Theme
Security
Documentation
Tests