You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6927c3f
Browse filesBrowse the repository at this point in the historyBrowse files
fix(plugin-auth)!: a self-serve social creation is admitted only with a provider-verified address under an address-based posture (#35200)
Clause-②: no (narrowing: a creation admitted today is refused; owes one
CONTRACT_REVIEW_TIER review before the queue)
Metadata-protocol: none
Skills-docs: none — no skill under `skills/**` teaches the audience
posture or a social-provider sign-in;
`content/docs/permissions/authentication.mdx` and
`content/docs/deployment/tenancy-modes.mdx` gain the rule in this
change.
No-card security order (seat `security#1`); there is no issue to close.
## 维护者速读
- 改了什么:`email_domain` 准入模式下,以及 `open`
模式在邮箱验证生效时,经社交登录(`socialProviders`)新建账号,只有在提供方报告邮箱已验证时才准入;否则在准入闸门处以 `403
SELF_REGISTRATION_CLOSED` 拒绝,与 `invite_only`
一致:不建账号、不发会话、不建成员关系。发给该地址的待处理邀请也不放行这种创建。
-
为什么改:执行维护者对本单的裁决:准入建立在邮箱地址之上的模式,社交登录新建账号须由提供方验证该地址;规则按创建类别判定,之后新增的社交提供方自动覆盖,不需逐个登记。
- 风险与回滚:BREAKING(窄化)。在 `email_domain`、或验证生效的 `open`
部署上,依赖「提供方报告未验证邮箱」也能注册的社交登录改为被拒。运营方注册的身份提供方(`oidcProviders`、SSO)、管理员创建、SCIM、全新安装的首个账号、部署声明关闭验证的
`open` 均不变。回滚即 revert 本 PR。
- 先看:`packages/plugins/plugin-auth/src/audience-posture.ts` 的
`decideAudienceAdmission`(���表守卫之后、邀请豁免之前新增的一条判定)与
`admissionRestsOnAddress`;`auth-manager-membership-admission.ts`
向判定传入的三个输入;`invitation-acceptance-verified-address.test.ts` 末尾新增的顶层
describe。
- 两分钟验证:`pnpm --filter @objectstack/plugin-auth exec vitest run
src/invitation-acceptance-verified-address.test.ts
src/audience-posture.test.ts`,预期 2 个文件、125 个用例全绿。
- 需要你做的:无,席位落地(窄化在入队前先有一次 CONTRACT_REVIEW_TIER 审核记录)。
## What changes
**The rule.** Under an audience posture whose admission rests on the
address (`email_domain` always; `open` while email verification is in
force), a self-serve creation through a social provider is admitted only
when the provider verified the address. Otherwise it is refused at the
admission gate with `403 SELF_REGISTRATION_CLOSED`, as `invite_only`
already refuses it: no account row, no session, no membership. The
binding rule and ADR-0093 are unchanged.
- `packages/plugins/plugin-auth/src/audience-posture.ts`:
`decideAudienceAdmission` gains the rule as one predicate, after the
creation-class exemptions, the bootstrap carve-out and the vocabulary
guard, and before the invitation carve-out and the posture switch, so
every admit after it is covered. Its input gains `method`,
`emailVerified` (verified only when it is `true`) and
`declaredEmailVerification`, which the decision resolves through
`resolveEmailVerificationRequirement`, the resolver the better-auth
wiring and the public config already read; absent resolves to the
posture default, so under `open` the rule holds unless the deployment
declared an explicit `false`. Two module-private helpers:
`isSocialProviderCreation` (a `self-serve` creation whose method is
`oauth`, which is how a social provider is told apart from an
operator-registered `oidcProviders` entry, already classed `provider`)
and `admissionRestsOnAddress`. The module doc gains the section "A
social provider's word on the address", and the invitation carve-out
paragraph names the exception.
-
`packages/plugins/plugin-auth/src/auth-manager-membership-admission.ts`:
`validateAudienceAdmission` hands the decision the vendor's
`source.method`, `user.emailVerified` and the live
`emailAndPassword.requireEmailVerification`. Nothing else in the gate
moves.
- `content/docs/permissions/authentication.mdx` (OAuth callback
section), `content/docs/deployment/tenancy-modes.mdx` (membership
reconciler bullet) and `content/docs/deployment/self-hosting.mdx` (the
`email_domain` invitation paragraph and "Email verification under each
posture") state the rule.
- `.changeset/social-creation-needs-provider-verified-address.md`:
`patch` on `@objectstack/plugin-auth`, the two declaration lines,
`Skills-docs:`, the ADR-0087 disposition and the BREAKING note with what
to do.
**Decisions this order left to the PR, and which way each went:**
- **The off-allowlist invitation case takes the same refusal.** Under
`email_domain`, an address off the allowlist that a pending invitation
is addressed to, signing in through a social provider that did not
verify it, is now refused like any other unverified social creation,
rather than keeping the outcome #34969 pinned for it. Why: the
invitation is matched by the very address the provider did not verify,
and `invite_only` already refuses an unverified OAuth creation whatever
invitation is addressed to it (`invitationProofFor`), so one rule reads
the same under every posture and the refusal leaves nothing behind.
Nobody is dead-ended: once the provider verifies the address the same
person is admitted and accepts the invited role (pinned), and the
email-and-password sign-up and the invitation mail's one-step link keep
working as before. The same holds for an invitation under `open` with
verification in force.
- **The bootstrap carve-out stays ahead of the rule**, as it does under
`invite_only`: the first account of a fresh install is admitted whatever
the provider said (pinned at the decision level).
- **The refusal reuses `SELF_REGISTRATION_CLOSED`**, the code
`invite_only` already answers this creation with, with its own
description naming the posture. No error code is added, so the ADR-0112
ledger does not move.
- **An off-allowlist address with no invitation** now meets this refusal
rather than `EMAIL_DOMAIN_NOT_ALLOWED` when the provider did not verify
it, because the rule sits ahead of the posture switch; with a verified
address it still meets `EMAIL_DOMAIN_NOT_ALLOWED`. Every non-social
creation keeps its refusal codes.
## Tests
All counts below are vitest's own summary lines; red was taken on the
unfixed source, green and the ablation on `9f4fd3cd`.
- **Red before the fix, on the real engine** (`AuthManager` over
`@objectstack/driver-sql` on better-sqlite3, the real `/sign-in/social`
door): 10 of the new pins fail and every control passes (`Tests 10
failed | 115 passed (125)`). The red set includes the three real-engine
refusal pins (`email_domain` on the allowlist, `open` with verification
in force, the off-allowlist invitation case).
- **Green after the fix**: `Tests 125 passed (125)` on the two files;
`144 passed` across those two plus `presented-invitation.test.ts` and
`audience-bootstrap-seam.test.ts`; the whole package `Test Files 285
passed (285)`, `Tests 6014 passed | 10 skipped (6024)`.
- **Ablation** (`scripts/ablation-replace.mjs`, wrap mode, with a trap
restore): the predicate's first operand replaced so the rule never
fires. Mutation proven on disk (anchor x1 -> x0, blob `f2f2b8a4` ->
`1879d950`); the run reds exactly the 10 refusal pins (`Tests 10 failed
| 115 passed (125)`) while every control stays green; restored blob
equals HEAD (`f2f2b8a4`) and `git diff HEAD` is empty.
New pins, named by the rule:
- `invitation-acceptance-verified-address.test.ts`, new top-level
describe "under an address-based audience posture, a self-serve social
creation is admitted only with a provider-verified address": refusal
under `email_domain` on the allowlist and under `open` with verification
in force (403 `SELF_REGISTRATION_CLOSED`, not signed in, and the
`sys_user` / `sys_account` / `sys_session` / `sys_member` row counts
unchanged); CONTROL: a provider-verified sign-in admits, signs in and
binds to the default organization under both; CONTROL: `open` with the
deployment's verification declared off admits as before.
- Same file, the `email_domain` invitation describe: the off-allowlist
invitation case is refused with nothing written and the invitation still
pending, then the provider-verified sign-in is admitted and accepts the
invited role.
- `audience-posture.test.ts`, two new top-level describes: the decision
matrix (only `emailVerified === true` counts; `email_domain` whatever
the deployment declares; an invitation does not admit; `open` refused
while verification is in force; CONTROL rows for `open` with
verification off, the `provider` and `operator` classes, every other
self-serve method, the bootstrap carve-out and `invite_only`) and the
real manager's gate (any social providerId, one configured later
included, refused; an `oidcProviders` entry and an `sso-oidc` provider
admitted whatever they said; `open` forced vs declared off).
## Acceptance notes
- Three existing cases in
`invitation-acceptance-verified-address.test.ts` drove a social account
whose provider did not verify the address under `open` with verification
in force; that creation is now refused. They now run under `open` with
the deployment's verification declared off (`OPEN_VERIFICATION_OFF`),
the one deployment where such an account is still created, so the
accept, decline and listing rules for it stay exercised; their
assertions are unchanged.
- That file's `deployment()` now boots the self-registration permission
set for `open` as well as `email_domain`, because an uninvited sign-up
under `open` is granted the declared set; no existing case's outcome
depends on it.
- The console's callback page maps `SELF_REGISTRATION_CLOSED` to its
"not invited" sentence
(`ui/apps/console/src/pages/auth/ssoCallbackRefusal.ts`), whose docblock
names only the `invite_only` emitter. For this refusal an invitation is
not the remedy; the server's description, behind the page's technical
details, names the remedy. Not changed here (outside this order's file
surface); raised as an open question in the report.
- The rule is told by creation class and method, so it covers every
`oauth` creation that is not an `oidcProviders` entry, a social provider
added later included. Other self-serve methods are unchanged by design:
email-and-password keeps its forced verification before a session, and
magic link and email OTP prove the mailbox in their own flow.
- `auth-manager-auth-instance.ts` is not touched: the forced
verification there still reaches `emailAndPassword` only, and the rule
lives in the admission decision instead of a per-provider requirement.
## Verification
Local subset at `bf6fa3de` (CI runs the full farm):
- `pnpm --filter @objectstack/plugin-auth typecheck` (with the package
built): exit 0, `check:test-typecheck: OK` with the test-layer debt
unchanged.
- `pnpm --filter @objectstack/plugin-auth exec vitest run
--maxWorkers=2`: exit 0, 285 files, 6014 passed, 10 skipped.
- The diff-derived gate list (`node scripts/pm/dispatch-gates.mjs
--commands --repo objectstack-ai/objectstack`): 100 families derived
from merge base `c480f335`; 99 exit 0, 1 NOT MEASURED: `pnpm
check:dual-build-cjs-loads` exit 3 (PREREQUISITE NOT MET, it reads every
package's built output and needs a repo-wide `pnpm build`; CI's `Lint &
Repo Gates` runs it). Two first runs exited 3 and were re-run after
meeting their prerequisite: `node
scripts/check-plugin-teardown-shape.mjs --self-test` (its pinned fixture
commit fetched into this shallow clone) exit 0, and `pnpm --filter
@objectstack/spec run check:skill-examples` (after building
`@objectstack/client-react` and its closure) exit 0. `--ran`
reconciliation: `100 derived, 99 run, 1 NOT-MEASURED, 0 UNRUN`, every
line carrying its exit code. `test:repo` is not run locally (no file of
that project is in the diff); CI's `Test Core` runs it.
- Dogfood battery on the final head: `bf6fa3de`, closure built (`pnpm
--filter '@objectstack/dogfood^...' build`, exit 0), then `pnpm --filter
@objectstack/dogfood test` under the verify lock: `VERDICT command-exit
0`, `Test Files 480 passed | 3 skipped (483)`, `Tests 4075 passed | 68
skipped (4143)`.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01ASNY8VyogmQQgdcx5jLwwc)_
<!-- signed: security#1 · os-mickey · session_01ASNY8VyogmQQgdcx5jLwwc
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
fix(plugin-auth)!: a self-serve social creation is admitted only with a provider-verified address under an address-based posture
6
+
7
+
Clause-②: no (narrowing: a creation admitted today is refused; owes one CONTRACT_REVIEW_TIER review before the queue)
8
+
Metadata-protocol: none
9
+
Skills-docs: none — no skill under `skills/**` teaches the audience posture or a social-provider sign-in; `content/docs/permissions/authentication.mdx` and `content/docs/deployment/tenancy-modes.mdx` gain the rule in this change.
10
+
11
+
<!-- adr-0087: not-required (no-migration-prescription) No schema key, accepted value or metadata type is added, removed, renamed or re-shaped. The moved answer is an account the admission gate does not create, so there is nothing stored for a migration to rewrite and no tombstone. -->
12
+
13
+
**BREAKING** for a deployment under the `email_domain` audience posture, or under `open` while email verification is in force, where people create their account by signing in through a social provider that reports the address unverified.
14
+
15
+
- Under `email_domain`, and under `open` while email verification is in force (the default there; only the deployment can declare it off), a new account through a social provider (`socialProviders`) is created only when the provider reports the address verified. Any other is refused `403 SELF_REGISTRATION_CLOSED` at the admission gate, as `invite_only` already refuses it: no account, no session, no membership. A browser sign-in redirects with `error=SELF_REGISTRATION_CLOSED`.
16
+
- A pending invitation addressed to that person does not admit the creation either, under both postures: the invitation is matched by the same address.
17
+
- The rule is told by the creation class, not by a list of providers, so a social provider added later is covered without being named.
18
+
19
+
Unchanged: a social provider that reports the address verified, which is admitted and bound as before; identity providers an operator registers (`oidcProviders` entries and SSO providers); accounts an administrator creates, SCIM provisioning and accounts a boot command provisions; the first account of a fresh install; email-and-password, magic-link and email-OTP sign-ups; `open` with the deployment's email verification declared off; and the `invite_only` posture.
20
+
21
+
What to do: a person refused this way verifies the address with the social provider and signs in again, or, where the deployment offers it, signs up with email and password and completes the verification mail. An invited person can also open the invitation mail's own link, which verifies the address and accepts in one step.
it('email_domain: refused unless the provider verified the address, for any social provider; an oidcProviders entry and an SSO provider are admitted whatever they said',async()=>{
0 commit comments