Repository navigation
fix(plugin-auth): Setup > Authentication says when email and password sign-in runs other than its switch shows - #38094
Conversation
…gn-in as it runs Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK
📓 Docs Drift Check21 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run. What this run could not see
Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 612c8df7eaabb91d71037b36af9058b5f4bbfb57 && git checkout 612c8df7eaabb91d71037b36af9058b5f4bbfb57
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin f72f335393f40e27194c56911e6de46052cb6f4c 022ffdfd80121895dba020055859236842bfc094 && git checkout -B drift-repro f72f335393f40e27194c56911e6de46052cb6f4c && git merge --no-ff 022ffdfd80121895dba020055859236842bfc094
node scripts/docs-audit/affected-docs.mjs --json f72f335393f40e27194c56911e6de46052cb6f4c |
|
repo:objectstack#6 · hotlong · session_01Q4EjjQkY5yXZrN9BEA3rEK 维护者速读
席位核对 — ACCEPT · repo:objectstack#6 · head
|
|
repo:objectstack#6 · hotlong · session_01Q4EjjQkY5yXZrN9BEA3rEK Landing: seat ACCEPT 7232512706 at head |
…ployment runs when nothing is saved (objectstack-ai#38180) Fixes objectstack-ai#38098 Clause-②: yes (narrowing) — narrowed: with nothing stored, `SettingsService.get('auth', …)` and `GET /api/settings/auth` answer `email_password_enabled`, `signup_enabled` and `require_email_verification` with the deployment's declaration (still `source: 'default'`) where they answered the manifest default, so a published response's value changes for an existing reader on any deployment whose own configuration differs from the manifest default for one of those keys; on a cloud-managed runtime whose deployment declares `emailAndPassword.enabled: false`, a save of `email_password_enabled: true` with nothing stored answers `400 SETTINGS_VALIDATION` and saves nothing in the batch, where it saved a row that was not applied; a save that sets one of these keys to its manifest default where the declaration differs now asks the key's write predicates. Widened: `SettingsService.registerDeclaredDefault` and the type `SettingsDeclaredDefault` (service-settings); `AuthManager.resolveDisableSignUp` (public method); a save that sets one of these keys to the declaration with nothing stored is no change and asks no predicate; on a deployment that declares `emailAndPassword.enabled: false` with nothing stored, the ten `auth` keys visible only while `email_password_enabled !== false` (`signup_enabled`, `require_email_verification`, `password_min_length`, `password_max_length`, `password_reject_breached`, `password_require_complexity`, `password_min_classes`, `password_history_count`, `password_expiry_days`, `mfa_required`) are hidden, so a save of one of them is no longer judged for `required`, options or bounds (for example `password_min_length: 2` is now stored where it was refused `400 SETTINGS_VALIDATION`), as under a stored `email_password_enabled: false`; a save that turns `email_password_enabled` on re-judges them. The live-status banner drops its declared-off, nothing-saved statement (`declaredOffLabel` / `declaredOffText` copy removed) and the cloud-managed statement is always a `warning`. Metadata-protocol: none Skills-docs: none — no skill under `skills/**` teaches the auth settings page, these switches or the settings cascade's bottom rung; `content/docs/protocol/kernel/config-resolution.mdx` states the declared default in this change. ## 维护者速读 - 管理员在 设置 → 认证 里、没保存过值时,邮箱/密码登录、自助注册、邮箱验证三个开关显示部署实际在跑的状态,不再显示清单默认值;托管环境同样如此。 - 属于托管云环境的统一登录工作,接着上一轮的提示横幅(那轮只加了一条说明,开关本身仍显示「开」)把开关本身改对。 - 出错时管理员会在没保存值的情况下看到开关显示错误的状态,或托管环境里打开邮箱/密码登录的保存被拒;已保存的值不受影响,可直接撤回本改动。 - 改动了设置决策记录(ADR-0007)的一条级联规则,需要你批准合并。 ## What changes **The seam (service-settings).** `SettingsService.registerDeclaredDefault(namespace, key, provider)` lets the package that owns a running config state what a key takes while nothing is stored and no `OS_*` override is in force. One private reader, `defaultOf`, answers the bottom rung of the cascade from the provider, else the manifest `default`, and every site that read the manifest default now reads it: the cascade walk (`get`, `getMany`, `getNamespace`, so `GET /api/settings/:namespace` and the write-predicate change test), the value a cleared key falls back to in `validatePatch`, and the type an `OS_*` value is coerced to. Asked on each use, never recorded (the startup-registry rule). `undefined`/`null` means nothing declared; a throwing provider is said once at `warn` and the manifest default answers (functional degradation, nothing persisted is lost). A provider that answers a promise is refused the same way (the contract is synchronous; the cascade reads it inline). The answer is not judged against the specifier's type or options: it is the running system's own value. A key or namespace with no provider resolves byte-for-byte as before. **What `source` reads.** Kept as `'default'`. The published enum (`ResolvedSettingValueSchema.source` in `packages/spec`) is `env | global | tenant | user | default` and admits no distinct value, and the seat ruled no spec shape change. The reading for existing consumers: `source: 'default'` meant "nothing stored, the manifest default"; it now means "nothing stored, the deployment's default" — still nothing stored, and a clear still returns to it. The consumers that branch on it keep their behaviour: `bindAuthSettings` applies only non-`default` sources (`isExplicit`), so a declared default is never re-applied (the running config already holds it); the restore-on-clear pass (`authSettingsFromStore`) is unchanged; the console renders `values[key].value`. ADR-0007 §Resolution rung 4 is amended in this PR (status line + amendment note), per Prime Directive 13. The spec's own account of the rung (`settings-manifest.zod.ts` file header and the `SpecifierScope` comment, `sys-setting.object.ts` header) now reads the same, and `content/docs/references/system/settings-manifest.mdx` is regenerated (`check:generated --fix`); comments only, no schema moves. **The declarations (plugin-auth, `auth-settings-declared-defaults.ts`).** Re-measured on base `0e361201` first (reverse-verification run below, before the fix): all three differ. | key | manifest default | declared default (what runs with nothing stored) | measured on base | |:---|:---|:---|:---| | `email_password_enabled` | `true` | `emailAndPassword.enabled !== false` | declared `false` → resolved `{true, default}` while `getPublicConfig().emailPassword.enabled` is `false` | | `signup_enabled` | `true` | `!AuthManager.resolveDisableSignUp(declared.disableSignUp)` (forced off under SSO-only / cloud-managed, then `OS_DISABLE_SIGNUP`, then the declaration) | declared `disableSignUp: true` → resolved `{true, default}` while `disableSignUp` runs `true` | | `require_email_verification` | `false` | `resolveEmailVerificationRequirement(posture in force, declared)` | declared `true` → resolved `{false, default}` while verification runs `true` | `AuthManager.resolveDisableSignUp` is the formula `getPublicConfig()` already used, extracted so the declaration and the public config cannot disagree. Registered in `bindAuthSettings` next to the sign-in floor; a settings surface without the method is skipped like the surface's other optional methods. **The banner (objectstack-ai#38094), reduced.** With the declaration as the value, the declared-off/nothing-saved case and the managed/nothing-saved case agree with what runs and state nothing. Left: a value stored on that a cloud-managed runtime does not apply (now always `warning`), and any other disagreement (`warning`). The `declaredOffLabel` / `declaredOffText` copy is removed from all 11 locales. **The managed save of `true` (objectstack-ai#38028).** With nothing stored on a managed runtime that declared email and password off, the key now resolves `false`, so a save of `true` is a change, reaches the `email_password_enabled` save door and is refused `400 SETTINGS_VALIDATION` (`invalid_value`, `constraint: { cloudManaged: true, declaredEmailPassword: false }`). The settings pass's not-applied hold stays for rows stored before the door existed. **Read first (by risk):** 1. `packages/services/service-settings/src/settings-service.ts` — `defaultOf` and its three call sites (`resolveKeyFromRows`, `validatePatch`, `effectiveEnvOverride`). 2. `packages/plugins/plugin-auth/src/auth-settings-declared-defaults.ts` — the three formulas. 3. `packages/plugins/plugin-auth/src/sign-in-method-floor.test.ts` — the managed describe, whose first case changed meaning (save of on with nothing stored: was stored-and-not-applied, now refused). ## Tests - New `service-settings/src/settings-declared-default.test.ts` (7): declared value read as `source: 'default'` through `get` / `getNamespace` / the cascade chain, asked on each read; CONTROL key and namespace with no provider; stored value wins and a clear returns to the declaration; `OS_*` wins; a write predicate sees the declaration as `current` (manifest default is a change; re-saving the declaration is not); `undefined` and a throwing provider leave the manifest default (said once); unknown namespace / key refused. - `plugin-auth/src/auth-settings-live-status.test.ts` (real `AuthPlugin`, real `SettingsService`, real `GET /api/settings/:namespace`): declared off, nothing stored → `{ value: false, source: 'default' }` through `SettingsService.get` and the route, no banner; CONTROL declared on → `true`, no banner; stored value wins both ways and a clear returns to the declaration; managed: nothing stored reads off with no banner, a row stored on before boot is not applied and is stated as a `warning` (en, zh-CN); `signup_enabled` declared off / SSO-only / CONTROL; `require_email_verification` declared on / `email_domain` posture / CONTROL. - Rework round (contract review S1 and N5): `settings-declared-default.test.ts` adds a promise-answering provider (manifest default, said once), a patch clear that takes the declaration for the visibility map (a required key behind it is not judged; CONTROL without provider refuses `SETTINGS_VALIDATION` / `required`), and an `OS_*` value read as the declaration's type where the manifest declares no default. `auth-settings-live-status.test.ts` adds `signup_enabled` under `OS_DISABLE_SIGNUP` and cloud-managed, and the hidden-key accept set: declared off with nothing stored, `password_min_length: 2` is stored, a later save of `email_password_enabled: true` re-judges and refuses it; CONTROL declared on refuses the same save. - `plugin-auth/src/sign-in-method-floor.test.ts`, managed describe: new first case pins the managed save of `true` with nothing stored refused (envelope `SETTINGS_VALIDATION` + field `invalid_value` + constraint, and `400` + `SETTINGS_VALIDATION` through the real `PUT` route); the two cases that needed a stored on now seed the row before boot; the Google case now also carries the `email_password_enabled` refusal. ## Acceptance notes - Other `auth.*` keys whose deployment declaration can differ from the manifest default (`password_min_length`, `password_max_length`, `membership_policy`, `mfa_required`, session and lockout windows, rate limits; the rows of `AUTH_SETTING_RESTORE`) still read the manifest default with nothing stored, and a `signup_enabled` stored on under SSO-only or cloud-managed shows on while sign-up is forced off, with no statement (unchanged here). Both are carried by follow-up card objectstack-ai#38184. - The served manifest still carries each specifier's manifest `default`; the console's default hint reads the cascade chain's `default` entry, which the declaration now answers, so hint and value agree. - Open nits from the contract review, not taken here: the `OS_*` coercion type follows the declaration (identical for the three boolean keys); `SettingsDeclaredDefault` takes no context (an optional argument can be added later without breaking); the `differs` banner sentence says "the saved setting", inexact only where the seam is missing or a provider throws with nothing stored. - No changeset for `@objectstack/spec` or `@objectstack/platform-objects`: their change is comments only, both sit in the fixed release group, and no gate asks for one. - Self-hosted, declared off, nothing stored: a save of `email_password_enabled: false` is now no change and asks no predicate (before, the sign-in floor judged it as turning off). It stores the value that already runs. ## Verification <details><summary>Reverse verification on base</summary> Fix committed; `packages/services/service-settings/src/settings-service.ts` restored from base `0e361201` with `git restore --source` (unstaged), the three test files run, then restored with `git restore --source=HEAD --staged --worktree` (`git status --porcelain` empty): - `settings-declared-default.test.ts`: 7 failed of 7 (`registerDeclaredDefault is not a function` — the seam does not exist on base). - `auth-settings-live-status.test.ts` + `sign-in-method-floor.test.ts`: 7 failed, 65 passed. Failures at the declared-value assertions (`expected value false, received true` for email and password and sign-up; `expected true, received false` for verification), after each case's running-config assertion passed; the managed save case and the Google case fail because the save of `true` is not refused. Every CONTROL case passed on base. </details> <details><summary>Local runs at final head 35da5d7 (after the rework round and a merge of origin/main)</summary> - Dependency closure rebuilt (`pnpm --filter '@objectstack/dogfood^...' build`), then `pnpm --filter @objectstack/service-settings typecheck && test`: Test Files 79 passed (79), Tests 1545 passed (1545); `pnpm --filter @objectstack/plugin-auth typecheck && test` (tsc, the examples project, `check:test-typecheck`): Test Files 296 passed (296), Tests 6310 passed, 10 skipped (6320). Lock verdict `command-exit 0` for the chain. - Dogfood battery at `35da5d7b` (`pnpm --filter @objectstack/dogfood test` under the verify lock): Test Files 491 passed, 3 skipped (494); Tests 4148 passed, 68 skipped (4216); lock verdict `command-exit 0`. - Derived gate families (`node scripts/pm/dispatch-gates.mjs --commands`, 127): `--ran` reconciliation 127 derived, 124 run with exit 0, 3 NOT MEASURED (exit 3, prerequisite): `node scripts/check-plugin-teardown-shape.mjs --self-test` (pinned fixture needs an unshallowed clone), `pnpm check:dual-build-cjs-loads` and `pnpm --filter @objectstack/spec run check:skill-examples` (read built output of packages outside the closure built here). `pnpm --filter @objectstack/spec check:generated`: 14 of 14 artifacts current after `--fix` regenerated the settings manifest reference page. Families CI runs are read from this PR's check-runs, not re-run here. </details> Two-minute check: `pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/auth-settings-live-status.test.ts` — 11 passed; the first case shows `email_password_enabled` read as `{ value: false, source: 'default' }` with no banner. --- _Generated by [Claude Code](https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK)_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Q4EjjQkY5yXZrN9BEA3rEK <!-- signed: repo:objectstack#6 · hotlong · session_01Q4EjjQkY5yXZrN9BEA3rEK --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Fixes #38029
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
With nothing stored,
auth.email_password_enabledresolves to the manifest default (true,source: 'default'), while the running auth config takes the deployment's ownemailAndPassword.enabled: the settings pass applies only stored orOS_*values, and the manifest default never rules (auth-settings-declared.ts). So a deployment that declares email and password off showed the switch on for a sign-in method that is off.plugin-authnow registers a live-status provider for theauthnamespace (the settings service'sregisterLiveStatusseam, the oneplugin-emailuses formail). On each page read it compares the switch (SettingsService.getwith the page's own context) with what runs (getPublicConfig().emailPassword.enabled), after any settings pass a change event started:infobanner, "Email and password sign-in is off on this deployment", saying the switch shows the console default and that a value saved here takes precedence;emailPasswordHeldOffByHost, the same predicate the managed save door and settings pass from the previous change read): "... off on this environment",infowith nothing stored,warningover a stored on that is not applied;warningnaming what runs.The banner reaches the page through
GET /api/settings/authas thelive_statusinfo_bannerat the head ofmanifest.specifiers, in the caller's language (all 11 platform locales, kept in the plugin like the mail statement's copy because it is composed per request).Why a banner and not the switch's value. The live-status
values/ servedlivefield admits option-bearing keys only and serves string option values (SettingsNamespacePayloadSchema.liveinpackages/spec), so a toggle cannot be stated there without a spec contract change; and makingvalues.email_password_enabledresolve to the declaration would change whatsource: 'default'means on a published shape. Both are contract decisions, not taken here (see Acceptance notes). The card's expected outcome allows "or marks the toggle as host-declared", which this does.Unchanged: the resolved
values, every save and the managed save door from the previous change. A stored value still wins where it is applied (pinned).Read first (by risk):
packages/plugins/plugin-auth/src/auth-plugin.ts, end ofbindAuthSettings: the provider registration and therunPasswrapper the provider awaits.packages/plugins/plugin-auth/src/auth-settings-live-status.ts,describeEmailPasswordLiveStatus: which case wins.packages/plugins/plugin-auth/src/auth-settings-live-status.test.ts.Two-minute check:
pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/auth-settings-live-status.test.tsshows 7 passed.Tests
New
auth-settings-live-status.test.ts(realAuthPlugin, realSettingsServicewith the shipped auth manifest, realGET /api/settings/:namespaceroute):SettingsService.getand the HTTPvaluesboth still answer{ value: true, source: 'default' }(the premise), and the page is headed by theinfobanner, in English and in zh-CN;infobanner with nothing stored,warningover a stored on that is not applied;warning; every locale carries every sentence.Premise and reverse verification
The fix was committed first (
ee523615);auth-plugin.tswas then restored from the base815e882b(unstaged,git restore --source) and the new file run: 2 failed, 5 passed. The two failures are cases 1 and 4, each at the banner assertion (expected undefined to match object), after the case-1 assertions thatSettingsService.getand the HTTP route answer{ value: true, source: 'default' }with the runtime off had passed: the premise, measured on the HTTP route the page reads. Restored withgit restore --source=HEAD;git status --porcelainempty afterwards.Acceptance notes
email_password_enabled !== false(password length, complexity, and others) stay visible there; the banner states it. Making the switch show the running value needs either the servedlivefield to admit booleans, or a settings-service seam for a runtime-declared default; both change a published contract and are left for a decision.authkeys whose deployment declaration differs from the manifest default (for examplesignup_enabled,require_email_verification); not reached here, the card names onlyemail_password_enabled.Verification
Local runs
pnpm turbo run build --filter='@objectstack/plugin-auth^...' --concurrency=2: 35 tasks successful.pnpm --filter @objectstack/plugin-auth typecheck: passed (tsc --noEmit, the examples project,check:test-typecheckOK).pnpm --filter @objectstack/plugin-auth test: Test Files 296 passed (296); Tests 6305 passed, 10 skipped (6315); lock verdict command-exit 0.022ffdfd(node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --commands, 77):--ranreconciliation 77 derived, 74 run with exit 0, 3 NOT MEASURED (exit 3, prerequisite):node scripts/check-plugin-teardown-shape.mjs --self-test(its pinned fixture needs an unshallowed clone),pnpm check:dual-build-cjs-loads(reads built output of packages outside the closure built here),pnpm check:type-check-debt(its closure build did not get a turn on the shared verify lock, queue-timeout behind a sibling run). CI runs all three families' scans in its own jobs; they are read from this PR's check-runs, not re-run here.Human Minimum
packages/specholds no runtime logic.pnpm lintis the run CI owns (Lint & Repo Gates), not repeated locally.main, one pull request.packages/spectouched: its generated artifacts are regenerated and committed. (not touched)content/docs/references/,packages/*/CHANGELOG.mdorcontent/docs/releases/.Generated by Claude Code