Repository navigation
fix(plugin-auth)!: an origin an SSO register or update body names is trusted for that provider's discovery only - #34099
Conversation
…rusted for discovery only Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
…ns-trust-discovery-only
…trusted for that provider's discovery only The request's own origin check reads the deployment's configured trusted origins alone; the origins a /sso/register body names reach the register endpoint's discovery fetch and validation, as the companion origins do. Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
… trusted for discovery only; changeset Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
…ns-trust-discovery-only
📓 Docs Drift CheckThis PR changes 1 package(s): 3 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 3 release-owned page(s) also name something this change touched. These are read-only:
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 51dceea70d51420abb999e058e73e55f43a0b4a2 && git checkout 51dceea70d51420abb999e058e73e55f43a0b4a2
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin b29f2dd117f4d105d9377aac39f2823bc0dc9e65 027821da02010557112814611d6a606be85f178d && git checkout -B drift-repro b29f2dd117f4d105d9377aac39f2823bc0dc9e65 && git merge --no-ff 027821da02010557112814611d6a606be85f178d
node scripts/docs-audit/affected-docs.mjs --json b29f2dd117f4d105d9377aac39f2823bc0dc9e65
|
|
security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f Contract-review-handoff: review#2 — CONTRACT_REVIEW_TIER unavailable (the maintainer routes contract-tier reviews to the review seat, 2026-11-15T19:06Z) · head dc13f56 |
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract-review-claim: session_01L9qibxTeW8xHnxoHxWNHWW · head dc13f56 · 2026-11-15T19:09Z |
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract reviewServed-tier: Read at 2026-11-15T19:19Z. First review of this head; claim: comment 6899725201; lane request 6899700369 on mailbox #33873. Independence: implemented and dispatched by security#1 (sunhaolin); reviewed by os-tesla. Read, never reviewed (outside the diff): ① Derived judgmentsThe rule: an origin a register or update body names is trusted only for the server-side discovery fetch and validation of that provider, and never as an accepted The request-origin half holds on every door I could find.
The discovery half does not hold on every reader. M1. M1 (must-fix) — The before-hook has a second server-side discovery reader for the same provider on the same request: the sign-out-of-IdP capability check ( Tests. The new describe pins the request-origin half with the controls asked for: a body-named origin refused as S1 (should-fix) — N1 (nit) — the changeset subject reads ② Semver level
CI at this head: 62 check-runs, all completed; 40 success, 21 skipped, 1 cancelled. The cancelled run is a ③ Boundary flags
④ Design judgmentAgainst the published surface on The design is not finished, though. The rule names "discovery fetch and validation of that provider", and the tree has two readers of that kind on these doors: the vendor's, which the hand-off reaches, and the plugin's own capability check in the same hook, which it does not. The change reasons about the vendor's reader alone, on both doors, and that is where M1 comes from. A must-fix found here is a FAIL. Implemented-by: VERDICT: FAIL |
…ister or update body's origins Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
…pdate body's origins, for that read only Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
…origins; changeset text Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract-review-claim: session_01L9qibxTeW8xHnxoHxWNHWW · head f87435b · 2026-11-15T20:04Z |
|
security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f Delta review on |
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract reviewServed-tier: Read at 2026-11-15T20:11Z. Delta review of this head against FAIL 6899874194 at dc13f56; claim: comment 6900490763; taken on patrol as owed. Independence: implemented and dispatched by security#1 (sunhaolin); reviewed by os-tesla. Read, never reviewed (outside the diff): ① Derived judgmentsThe rule is unchanged: an origin a register or update body names is trusted only for the server-side discovery fetch and validation of that provider, and never as an accepted Prior M1: closed. The sign-out-of-IdP capability check (
Prior S1: closed. Prior N1: closed. The changeset subject reads New at this head. S1 (should-fix) — new. The hand-off that closes prior M1 is wider than the one verdict prior M1 named: the body-named origins reach more of the capability check than its verdict on the logout endpoint, as they did on S2 (should-fix) — new; continues the PR-body part of prior M1. The PR body was not brought to this head. Its "What changes" still says N1 (nit) — new. The CONTROL for a logout endpoint on a host the body does not name drives the register door only; the update door shares the function and the helper has its own unit pin, so the gap is coverage symmetry, not behaviour. In the same family: the jsdoc on No must-fix. ② Semver level
CI at this head: 57 check-runs, all completed; 40 success, 17 skipped. Nothing is running, cancelled or red. This PASS is not rendered over running checks. ③ Boundary flags
④ Design judgmentAgainst the published surface on The last head reasoned about one of the two discovery readers on these doors and narrowed the other without saying so. This head gives the second reader the body-named origins directly, in the function that needs them, on both doors at once, and writes the two readers down in the module header, the jsdoc, the changeset and the docs. For a request from a configured origin the tree now answers as Implemented-by: VERDICT: PASS |
…dy's origins for the logout endpoint only Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
…out check's logout-endpoint verdict only Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract-review-claim: session_01L9qibxTeW8xHnxoHxWNHWW · head 7a02d75 · 2026-11-15T21:03Z |
|
security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f Note for the delta on |
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract reviewServed-tier: Read at 2026-11-15T21:10Z. Delta review of this head against PASS 6900594238 at f87435b; claim: comment 6901328026; taken on patrol as owed. Independence: implemented and dispatched by security#1 (sunhaolin); reviewed by os-tesla. Read, never reviewed (outside the diff): ① Derived judgmentsThe rule is unchanged: an origin a register or update body names is trusted only for that provider's discovery and validation, and never as an accepted Prior S1 (hand-off wider than the logout-endpoint verdict): closed in the tree.
Prior S2 (PR body not brought to the head): changed, and now M1. The body was brought to Prior N1: closed. The update door has its own CONTROL for a logout endpoint on a host the body does not name, and the jsdoc on New at this head. M1 (must-fix) — continues prior S2. The PR body contradicts the head on the narrowing this head adds. Its maintainer digest tells the maintainer that a request from the Console or a configured origin is unaffected, "including a register or update that turns the logout switch on"; at this head that is false for the second mover the changeset names. Its "What changes" still describes the wider hand-off of S1 (should-fix) — new. The docs page does not carry the second mover to the reader. N1 (nit) — new. Test names lag the rule: the unit case for N2 (nit) — new. The four new cases install a double for the runner's environment; the older switch-on cases in the same describe do not and now lean on that environment where at ② Semver level
CI at this head: 53 check-runs; 37 success, 15 skipped, 1 in progress (the ③ Boundary flags
④ Design judgmentAgainst the published surface on The code agrees with the contract it implements: one extra input, one reader, both doors through one function, pins that go red on the ablation and CONTROLs that would catch an over-tight limit. The tree, the changeset and the code comments tell one story. The PR body tells the story of the last head, and on a BREAKING change the body's risk line is what the maintainer reads before landing, so it has to name the second mover. That is the whole of M1; nothing in the tree needs to move for it. Implemented-by: VERDICT: FAIL |
…ases hermetic, pin the logout predicate input; name the remedy in docs Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract-review-claim: session_01L9qibxTeW8xHnxoHxWNHWW · head 027821d · 2026-11-15T22:01Z |
|
review#2 · os-tesla · session_01L9qibxTeW8xHnxoHxWNHWW Contract reviewServed-tier: Read at 2026-11-15T22:06Z. Delta review of this head against FAIL 6901428226 at 7a02d75; claim: comment 6902072922; taken on patrol as owed. Independence: implemented and dispatched by security#1 (sunhaolin); reviewed by os-tesla. Read, never reviewed (outside the diff): ① Derived judgmentsThe rule is unchanged: an origin a register or update body names is trusted only for that provider's discovery and validation, and never as an accepted Prior M1 (PR body contradicts the changeset on the second mover; stale readings; placeholders): changed. The must-fix part is closed; one residue remains, as S1 below.
Prior S1 (docs do not name who is refused or the remedy; the changeset's "documented setting" documented nowhere): closed. Prior N1 (titles lag the rule; no function-level case for the new input): closed. The unit case for Prior N2 (older switch-on cases not hermetic): closed. One helper, New defects from S1 (should-fix) — continues prior M1, its residue. The PR body still carries the literal N1 (nit) — new. Two wording leftovers in the PR body's "What changes". The second-narrowing bullet spells the remedy as N2 (nit) — new. The remedy lists the identity provider's origin in the deployment's trusted origins, which is also the list the request's own origin check reads. No must-fix. ② Semver level
CI at this head: 57 check-runs; 40 success, 17 skipped, none failed, cancelled or running ( ③ Boundary flags
④ Design judgmentAgainst the published surface on Each implementing file agrees with the contract it implements. Implemented-by: VERDICT: PASS |
|
security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f 席位核对ACCEPT at
Implemented-by: os-dev (security#1 order, |
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — no skill under
skills/**teaches trusted origins or SSO provider registration;content/docs/permissions/sso.mdxgains the rule in this change.维护者速读
OS_TRUSTED_ORIGINS。回滚即 revert 本 PR。packages/plugins/plugin-auth/src/auth-manager-auth-instance.ts(可信来源列表不再是按请求的函数)、src/auth-manager.ts(assertSsoSignOutOfIdpSupported只把请求体来源交给登出端点判定)、src/sso-sign-out-of-idp.ts、src/sso-discovery-companion-origins.ts。pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/sso-discovery-companion-origins.test.ts src/sso-sign-out-of-idp.test.ts,预期两文件全部通过(前者 27 例)。What changes
Rule. An origin taken from an SSO register or update request body is trusted only for the server-side discovery fetch and validation of that provider. It never becomes an accepted
Originfor the request's own origin check, which sees exactly the deployment's configured trusted origins, as on any other POST.auth-manager-auth-instance.ts: the auth instance'strustedOriginsoption is the configured list with the SSO relying party wired too; it is no longer a per-request function.auth-manager.ts:ssoDiscoveryTrustedOriginsreads the parsed body (the same issuer andoidcConfigendpoints, public-routable hosts only) instead of the raw request. It is the one definition of the body-named set, and two server-side readers of the provider take it: the vendor's discovery and validation, and the sign-out check's logout-endpoint verdict:/sso/registerdiscovery and endpoint validation: the global before-hook (auth-manager-before-hook.ts) hands the set, with the existing companion origins, to that endpoint as a per-endpoint context change (ssoDiscoveryCompanionContext). This is the seam the companion origins already use: the vendor merges it into the endpoint's own context after its router-level origin check has run;assertSsoSignOutOfIdpSupported) on/sso/registerand/sso/update-provider, when the request turnssignOutOfIdpon: its verdict on the provider's OIDC logout endpoint alone trusts the body-named set beside the configured list, throughtrustingBodyNamedOrigins(sso-discovery-companion-origins.ts), an exact-origin match the same as the vendor's.judgeSignOutOfIdpCapability(sso-sign-out-of-idp.ts) takes that predicate as a separate input,isTrustedLogoutOrigin; the discovery document it reads to find the endpoint is fetched under the configured trust (isTrustedOrigin)./sso/update-providerendpoint itself fetches no discovery document, and its endpoint validation admits any public-routable host on its own, so the body-named set (public-routable only) changes none of that endpoint's verdicts. The sign-out capability check's logout-endpoint verdict on update is the one reader there, and it takes the set as above.signOutOfIdpon for an OIDC identity provider on a private network is refused400 VALIDATION_FAILEDonsignOutOfIdpuntil that provider's origin is in the deployment's trusted origins (OS_TRUSTED_ORIGINS, or thetrustedOriginsoption).mainsaved it. The changeset declares it under "Who moves, too".content/docs/permissions/sso.mdx: states the rule, which checks read a body-named origin on each door, and that the sign-out check's discovery read keeps the configured trust..changeset/sso-body-origins-trust-discovery-only.md:patch, BREAKING, with "Who moves" and the ADR-0087not-requiredmarker.Tests
src/sso-discovery-companion-origins.test.ts, a top-level describe in the shared harness (a realAuthManagerwith the realsso()plugin over the in-memory engine, the origin check on as a deployment runs it):Originequal to the body-named issuer is refused by the origin check (403 INVALID_ORIGIN); no provider row is written;Originequal to a body-namedoidcConfigendpoint's host is refused; no row is written;Originequal to a body-named host is refused, for an endpoint and for an issuer; the provider row is unchanged;signOutOfIdpon, anOriginequal to a body-named host is still refused, on register and on update; nothing is written or changed;400 VALIDATION_FAILEDonsignOutOfIdp), on register (nothing is written) and on update (the row is unchanged);400 VALIDATION_FAILEDonsignOutOfIdpand nothing is written;discovery_untrusted_origin;Every switch-on case installs the identity provider's whole test environment (its discovery documents and its network placement), so none leans on the runner's own environment.
In the companion-origin table describe: the logout-endpoint verdict's predicate,
trustingBodyNamedOrigins, admits a body-named origin by exact origin only (another port, scheme, subdomain or protocol, or a non-URL, is refused), and with no body-named origin it is the request's own predicate.src/sso-sign-out-of-idp.test.ts:judgeSignOutOfIdpCapabilitywithisTrustedLogoutOrigingiven accepts a logout endpoint on the origin only that predicate trusts, while its discovery fetch receivesisTrustedOrigin; with it absent, the same endpoint is refused onsignOutOfIdp(the verdict falls back toisTrustedOrigin).src/auth-manager.test.ts: the SSO-wired pins assert the configured list (production with a list, production with none: key omitted, non-production: the localhost trio), never a function.Acceptance notes
ssoDiscoveryTrustedOrigins), and the auth-instance host dropsisSsoWired, which nothing there reads any more.register-sso-provider.tscomments were re-read and still state the rule (an endpoint the registration names is trusted for that registration); no change.origin/mainwas merged before the PR opened (atdc13f5644e). The round-2 commits were not followed by another merge: the commits onmainsince then touch neitherplugin-authnor its dependency closure, and there is no conflict.Verification
Readings at head
027821da02, unless a line names another commit. Source is unchanged since7a02d7506a; the commit after it changes tests, docs and the changeset only.Rule tests before the fix, on main's source (commit 44a24a6)
vitest run src/sso-discovery-companion-origins.test.ts: 3 failed, 15 passed. The three request-origin rule tests were red (each answered200where403is required), and every CONTROL was green, including the different-host refusal.Sign-out capability tests before the round-2 fix (commit dc13f56 plus the new tests)
vitest run src/sso-discovery-companion-origins.test.ts: 2 failed, 20 passed. The configured-origin register and update with the switch on were both refused400 VALIDATION_FAILEDonsignOutOfIdp; the CONTROL for a logout endpoint on a host the body does not name, and the request-origin refusals with the switch on, were green.Logout-endpoint-only narrowing, measured before the fix (CI at commit 18b8af0, the pins-first commit)
Test Core (7/8)on18b8af0cea: plugin-auth 3 failed, 5538 passed. The two limit pins answered200where400is required: before the limit, turning the switch on for a provider on a private network whose origin the deployment does not list was saved on both doors, as onmain. That is the verdict the changeset declares under "Who moves, too". The third red was the update-door CONTROL's own setup (its registration's discovery document published the foreign logout endpoint, which the vendor's register discovery refuses); the CONTROL now registers before that endpoint is published.Ablations (fix committed first, restored from HEAD)
dc13f5644e): mutation throughscripts/ablation-replace.mjsinauth-manager-auth-instance.ts, giving the trusted-origins option back the body-named origins for a register or update request. Anchor 1 to 0, blobeb0e0dd81971toc27bae0d860c. Run ofsso-discovery-companion-origins.test.tsandauth-manager.test.ts: 6 failed, 349 passed. Red: the three request-origin rule tests and the three SSO-wired configuration pins; every CONTROL stayed green. Restored: blob equals HEAD, marker count 0,git diff HEADempty. A first attempt of this mutation dropped the original's error handling and threw (500s on the controls too); it was discarded and the faithful one above is the reading.027821da02): mutation inauth-manager.ts, handing the widened predicate back to the whole capability check asisTrustedOrigin. Anchor 1 to 0, blob14c267f6a2acto5cdf115d1918. Run ofsso-discovery-companion-origins.test.ts: 2 failed, 25 passed. Red: exactly the two limit pins (register and update); every CONTROL stayed green, the listed-origin CONTROL included. Restored: blob equals HEAD (14c267f6a2ac), marker count 0,git diff HEADempty.f87435b23a): mutation inauth-manager.ts, giving the capability check no body-named origins. Anchor 1 to 0, blobeb3148fcb0c4toe790b896028c. Run ofsso-discovery-companion-origins.test.ts: 2 failed, 21 passed. Red: exactly the configured-origin register and update with the switch on. Restored: blob equals HEAD (eb3148fcb0c4), marker count 0,git diff HEADempty.Package build, typecheck and tests
pnpm --filter @objectstack/plugin-auth build: exit 0.pnpm --filter @objectstack/plugin-auth typecheck: exit 0.pnpm --filter @objectstack/plugin-auth test: Test Files 277 passed (277), Tests 5543 passed, 10 skipped (5553), exit 0.Derived gates
node scripts/pm/dispatch-gates.mjs --commandsat027821da02: 105 commands for this diff's 10 paths. All 105 run locally, each exit code recorded before any pipe: 102 exit 0, 3 exit 3 (PREREQUISITE NOT MET, nothing measured).--ranreconciliation: 105 derived, 102 run, 3 NOT-MEASURED, 0 UNRUN.check:type-check-debt(the shared verify lock was held by other dogfood batteries through two kept-place attempts), andcheck:skill-examplesandcheck:dual-build-cjs-loads(both read the whole workspace'sdist/, which that gate builds). CI at027821da02:Type Check · debt ledgersuccess andLint & Repo Gatessuccess.origin/mainon fivescripts/pm/files it derives from. The branch is not re-merged (see Acceptance notes), so the families are this head's.027821da02: Test Core, TypeScript Type Check, Lint & Repo Gates, Build Core, Governed Surface Queue Guard, Test UI, Live E2E UI, Dogfood Regression Gate and Check Changeset success; 38 success and 15 skipped in all, none failed or running.Dogfood battery
At
027821da02, under the verify lock, after building the dogfood dependency closure:pnpm --filter @objectstack/dogfood test, Test Files 467 passed, 3 skipped (470); Tests 3962 passed, 42 skipped (4004); VERDICT command-exit 0. Source is unchanged since7a02d7506a, so this reading covers that commit too. An earlier battery onf87435b23aread the same totals.Generated by Claude Code