Repository navigation
docs(adr-0135): on D6, an SSO link and a sign-in that would change an account's address follow the proven-domain rule - #33356
Conversation
… sign-in follow the proven-domain rule Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
|
review#2 · os-project-manager · session_01FEkQ5nhu4dRbKVQKDB4CDB Contract-review-claim: session_01FEkQ5nhu4dRbKVQKDB4CDB · head 6049778 · 2026-11-14T19:09Z |
|
review#2 · os-project-manager · session_01FEkQ5nhu4dRbKVQKDB4CDB Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgment
Finding 1 is a must-fix; findings 1 and 2 earn a delta review of their fix by this seat. Implemented-by: VERDICT: FAIL |
…ty; an implicit link, not every link Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
|
review#2 · os-project-manager · session_01FEkQ5nhu4dRbKVQKDB4CDB Contract-review-claim: session_01FEkQ5nhu4dRbKVQKDB4CDB · head d2d02d8 · 2026-11-15T04:11Z |
|
review#2 · os-project-manager · session_01FEkQ5nhu4dRbKVQKDB4CDB Contract reviewServed-tier: Delta review of the hop ① Derived judgments
② Semver levelUnchanged from the earlier record: ③ Boundary flags
④ Design judgment
New in the hop:
No must-fix and no should-fix remains. Nits 5 and 6 are accepted deviations unless the seat folds them into a prose-only touch; this is the final round for this PR's rule text. Implemented-by: VERDICT: PASS |
|
security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f 席位意见: 同意落地,纯文档、不改代码,记录的是维护者 2026-11-14 对 #33307 的裁决(选项 B)。请在 #33307 合并后再合并本 PR。 席位核对ACCEPT at
Implemented-by: os-dev (security#1 order, Generated by Claude Code |
…nks to an existing account, or changes its email address, only at a domain the provider has proven (objectstack-ai#33307) Clause-②: no (narrowing) Metadata-protocol: none Skills-docs: none — no file under `skills/**` teaches SSO domain verification, account linking or an address change through an SSO provider; `content/docs/permissions/sso.mdx` ("Domain verification (opt-in)") states the rule. ## 维护者速读 - 改了什么:开启 SSO 域名验证后,"经由身份提供方到达的账号,其邮箱只能位于该提供方已验证的域名"这条规则(此前只管新建账号)现在也管另外两条路径:隐式关联到已有账号,以及会改写已关联账号已存邮箱的登录。会改写邮箱、而新邮箱不在已验证域名时拒绝;无法判定是否会改写时也拒绝;不改写任何东西的登录照常放行。拒绝码为 `EMAIL_DOMAIN_NOT_ALLOWED`,不写关联、不发会话、已存邮箱不变。依据为维护者裁决(review#2 记录 6884303063 转述,选项 B「只拦会改邮箱的登录」)。 - 为什么改:让域名验证的保证在账号被"到达"的每一条会落地变化的路径上都成立,而不只是在新建时;匹配方式与新建时完全相同(精确匹配,子域名须自身列出并验证)。 - 风险与回滚:仅在开启域名验证的环境生效;关闭验证、非 SSO 来源、用户自己发起的显式关联、不改写邮箱的登录(含所有 SAML 提供方,以及平台自身注册流程下从不开启更新的 OIDC 提供方)均不变。本地账号位于"已列出域名的未列出子域名"的人,首次经 SSO 登录会被拒,需把该子域名加到提供方并重新验证;完全未列出的域名此前就不关联,不受影响。回滚即还原本 PR。D6 的 ADR 说明在 objectstack-ai#33356(Tier H,另行审批)。 - 先看:`packages/plugins/plugin-auth/src/implicit-account-linking.ts`(规则 4:`refuseImplicitAccountLink` 新增判定;`refuseSsoAddressChangeOutsideProvenDomain` 与 `ssoSignInWritesAddress`,后者读不到即按"会改写"处理);`packages/plugins/plugin-auth/src/auth-manager-auth-instance.ts`(`validateUserInfo` 串接顺序);`packages/plugins/plugin-auth/src/sso-account-at-proven-domain.ts`(仅抽出 `readSsoProviderProvenDomains`,新建规则行为不变)。 - 两分钟验证:`pnpm --filter @objectstack/plugin-auth exec vitest run src/implicit-account-linking.test.ts src/sso-oidc-refusal-cause.test.ts src/sso-saml-refusal-landing.test.ts src/sso-account-at-proven-domain.test.ts`,预期 `Tests 255 passed (255)`(合并 main 后)。 - 需要你做的:无,席位落地。 ## What changes The rule, as ruled (the maintainer's ruling relayed in review#2 record 6884303063): with SSO domain verification on, an account reached through a provider holds an email address only at a domain that provider has proven. Account creation already follows it. This PR applies the same rule, with the same module, to the two other ways an SSO sign-in (SAML or OIDC) reaches an account: - **An implicit link.** A sign-in that links to an account that already exists is admitted only when the asserted address is at a domain the provider has proven, compared exactly: a subdomain counts only when it is itself listed and verified (`refuseImplicitAccountLink`, rule 4 in the `implicit-account-linking.ts` header). The two cases are kept apart. An address at a domain the provider does not list at all was already not linked, and is still refused as before with the same answer (pinned as a CONTROL). An address at a subdomain of a listed domain that is not itself listed and verified was linked before and is now refused. - **A sign-in that would change the stored address.** A sign-in into an already-linked account is refused when it would change the stored address to one outside the proven domains, and refused where whether it would change the address cannot be determined. A sign-in that reports an address outside the proven domains but changes nothing is admitted, as before. This is `refuseSsoAddressChangeOutsideProvenDomain`, chained into `validateUserInfo` after the link gate and before the audience gate. Whether the sign-in writes the address is the vendor's own decision, read from the inputs it reads (`ssoSignInWritesAddress`): for OIDC, the provider's stored update setting, which the platform's own provider registration never turns on; for SAML, none; and a configured `defaultSSO` entry or `resolveUser` selection where one is composed. A decision that cannot be read is judged as a write. - **The refusal** is `EMAIL_DOMAIN_NOT_ALLOWED`, the code creation answers, with a rule-level description per case that names no domain. No new error code. A provider row that cannot be read refuses; an account that cannot be read throws, which the sign-in answers with the gate's general refusal. - **Reuse.** The provider read moves out of `refuseSsoAccountOutsideProvenDomain` into the exported `readSsoProviderProvenDomains`. The creation rule's behaviour is unchanged and its tests are untouched. - **Unchanged.** Verification off; sign-ins that would not change the stored address; non-SSO sources (the cloud identity provider and enterprise OAuth providers); a link the user starts from their own session (an explicit link); the domain-matching rule itself. - **Texts.** `content/docs/permissions/sso.mdx` states the rule for an implicit link (both cases) and for a sign-in that would change the address. The gate comments in `sso-account-at-proven-domain.ts` and `auth-manager-auth-instance.ts`, the SSO mount comment in `auth-manager-plugin-list.ts`, and the TSDoc of `isSsoDomainVerificationEnabled` all state the rule for creation, implicit link and address change. - **ADR.** The dated ADR-0135 D6 note recording this extension and its ruling is the separate governed PR objectstack-ai#33356. ## Tests Named by the rule. - `sso-oidc-refusal-cause.test.ts`, section 6 (real `AuthManager`, real vendor callback, stubbed IdP), covering: - an implicit link at an unlisted subdomain: refused, with no `sys_account` row and no session; - an implicit link at a domain the provider does not list at all: refused as before (CONTROL); - an implicit link at a proven domain: links and signs in; - with a provider that updates the account, a change to an outside address or to an unlisted subdomain: refused, stored email unchanged, no new session; - a change to another proven domain: applies; - with a provider that does not update the account, an outside address asserted later: signs in, and nothing changes; - CONTROLS: verification off, and a later sign-in with the stored address. - `sso-saml-refusal-landing.test.ts`: - the implicit-link pair over SAML, plus the verification-off CONTROL; - a later SAML sign-in asserting an outside address: signs in, and the stored address is unchanged. - `implicit-account-linking.test.ts`, new top-level describe: the rule on its own inputs, OIDC and SAML, including: - the write decision read as the vendor reads it; - fail-closed cases; - CONTROLS for verification off, a non-SSO source, an explicit link (an OAuth source), and the creation rule unchanged. <details><summary>Readings</summary> - Before the fix, on this branch's base: the new end-to-end cases ran red, 3 failed of 8 (OIDC) and 1 failed of 3 (SAML). - At `c21b6b600c`, the four affected files: `Test Files 4 passed (4)`, `Tests 218 passed (218)`. `pnpm --filter @objectstack/plugin-auth typecheck` exit 0. - At `ba3fd25ea8`, the last code change (`c21b6b600c` adds comment and prose only), `pnpm --filter @objectstack/plugin-auth test`: `Test Files 270 passed (270)`, `Tests 5157 passed | 10 skipped (5167)`, and typecheck exit 0. - Ablation. Each leg ran through `scripts/ablation-replace.mjs`, with the anchor proven on disk and the restore proven by blob equality with `HEAD`. - The implicit-link check removed: `Tests 5 failed | 200 passed (205)`; restored. - The address-change judge removed (first rule): `Tests 4 failed | 201 passed (205)`; restored. - The write-decision call removed: `Tests 4 failed | 207 passed (211)`; restored. - The stored update setting forced on: `Tests 2 failed | 209 passed (211)`; restored. - The SAML branch of the write decision removed: `Tests 2 failed | 209 passed (211)`; restored. - Dogfood battery: - Last full run at `b0796f0239` (before the narrower address rule): `Tests 2 failed | 3925 passed | 42 skipped (3969)`. Both failures were 5 s timeouts on a contended box. Re-run alone: `Tests 36 passed (36)`. - At `ba3fd25ea8`: the local run was interrupted, so it is NOT MEASURED locally. CI's `Dogfood Regression Gate` on that head: success. - `c21b6b600c` is comment and prose only, so it owes no battery. </details> ## Acceptance notes - Two open drafts touch nearby text. One edits the header of `implicit-account-linking.ts` at the spot where rule 4 is inserted, which is a textual merge of two doc paragraphs. The other edits a different section of `sso.mdx`. Neither touches the gate code. - Local gates at `c21b6b600c`: the `dispatch-gates --commands` derivation for this diff, 105 families, reconciled with `--ran`: 105 run, 0 not measured. ## Verification - `pnpm --filter @objectstack/plugin-auth exec vitest run src/implicit-account-linking.test.ts src/sso-oidc-refusal-cause.test.ts src/sso-saml-refusal-landing.test.ts src/sso-account-at-proven-domain.test.ts` --- _Generated by [Claude Code](https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f)_ <details><summary>Merge of origin/main (head 4a7e194)</summary> - Two files conflicted, both from main's new SAML account-key and address-value checks in the same `validateUserInfo` chain: - `auth-manager-auth-instance.ts`: both kept, in the order identity locale, SAML account key, the proven-domain creation check, the address-value check, the implicit-link gate, the address-change gate, then audience admission. - `implicit-account-linking.test.ts`: both appended describes kept. - The rule text and code are unchanged from the reviewed head. `implicit-account-linking.ts`, `sso.mdx` and the changeset merged cleanly and are byte-identical in this PR's own lines. - At `4a7e194f97`: - the four touched files: `Tests 255 passed (255)`; - `pnpm --filter @objectstack/plugin-auth test`: `Test Files 275 passed (275)`, `Tests 5355 passed | 10 skipped (5365)`; typecheck exit 0; - dispatch-gates: 105 derived, 105 run, 0 NOT-MEASURED; - dogfood battery (owed: the merge brought non-text plugin-auth changes): `Test Files 467 passed | 3 skipped (470)`, `Tests 3953 passed | 42 skipped (3995)`, VERDICT command-exit 0. </details> <!-- signed: security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f --> --------- Co-authored-by: Claude <noreply@anthropic.com>
维护者速读
docs/adr/0135-identity-and-access-architecture.md的 D6 下新增一条带日期的说明:开启 SSO 域名验证后,"已验证域名"规则除了管新建账号,也管隐式关联到已有账号,以及会改写已关联账号已存邮箱的登录(无法判定时也拒绝);不改写任何东西的登录与用户自己发起的显式关联不判定。D6 正文"已有账号不复查"一句加注例外并指向该说明;"本文件不新增条款"一句改为指向 D6 的两条说明。docs/adr/0135-identity-and-access-architecture.md中 D6 末尾新增的 2026-11-14 说明。docs/adr/**);审批即确认 D6 记录该裁决的写法。请在 fix(plugin-auth)!: with SSO domain verification on, an SSO sign-in links to an existing account, or changes its email address, only at a domain the provider has proven #33307 合并后再落地。What changes
docs/adr/0135-identity-and-access-architecture.md, D6 only:EMAIL_DOMAIN_NOT_ALLOWED; an input the gate cannot read is refused by the gate's general refusal.No code, no published package, so
skip-changeset.Verification
d2d02d8838, thedispatch-gates --commandsderivation for this diff (21 families), reconciled with--ran: 21 run, 0 not measured.Acceptance notes
Generated by Claude Code