Repository navigation
fix(plugin-auth): a kernel without SSO answers 404 again on the SSO discovery endpoints, with no error log - #36072
Conversation
…scovery endpoints Claude-Session: https://claude.ai/code/session_01Q4EjjPP1zuWBNq3nBXVei9 Co-authored-by: Claude <noreply@anthropic.com>
…nstance mounts SSO A kernel without SSO answered 503 SERVICE_UNAVAILABLE and logged an error on /sso/register, /sign-in/sso and /sso/callback/* because the scope opened on the path alone while its adapter observer mounts only with SSO. The scope now opens when the path names a discovery endpoint AND the built auth instance mounts the vendor's sso plugin, so an unmounted kernel answers the vendor's 404 again and a mounted one is judged exactly as before. Claude-Session: https://claude.ai/code/session_01Q4EjjPP1zuWBNq3nBXVei9 Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q4EjjPP1zuWBNq3nBXVei9 Co-authored-by: Claude <noreply@anthropic.com>
📓 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 25384849e56fda82b4d239c7fbfd4d6b13c7cd05 && git checkout 25384849e56fda82b4d239c7fbfd4d6b13c7cd05
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 615d99542a404ba2fd5e8f3d9840d07550a16254 1f505ba720c776fa93ebf1a57a35e53bba3372cc && git checkout -B drift-repro 615d99542a404ba2fd5e8f3d9840d07550a16254 && git merge --no-ff 1f505ba720c776fa93ebf1a57a35e53bba3372cc
node scripts/docs-audit/affected-docs.mjs --json 615d99542a404ba2fd5e8f3d9840d07550a16254
|
|
repo:cloud#5 · hotlong · session_01Q4EjjPP1zuWBNq3nBXVei9 ACCEPT 2026-11-21T12:45Z · head The seat read the diff: 5 files, +106 −4, all in
|
Fixes #35939
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
On a kernel that does not mount SSO (the default without
OS_SSO_ENABLEDorplugins.sso),POST /sso/register,/sign-in/ssoand/sso/callback/*answered503 SERVICE_UNAVAILABLEand logged one error line per request. The discovery-egress scope opened onisSsoDiscoveryEgressPath(path)alone, whilessoProviderReadsObserverPluginis pushed only insideif (enabled.sso), sorunSsoDiscoveryEgressfound no observed adapter and refused.sso-discovery-egress.ts: newmountsSsoEndpoints(auth). It reads the built instance's plugin list (auth.options.plugins, the same readimplicit-account-linking.tsuses for the composedssoplugin) and answers whether the vendor'sssoplugin is mounted. A list it cannot read answerstrue, so the scope opens.auth-manager-request-routing.ts: the scope opens when the path names a discovery endpoint ANDmountsSsoEndpoints(auth)holds. Unmounted: the vendor answers its own 404 and no provider read can happen. Mounted: unchanged. An unobserved adapter is still refused 503 before the endpoint runs.auth-manager.ts: a docblock line onrunSsoDiscoveryEgresssaying it is reached only when SSO is mounted.Why the composition and not
isSsoWired():isSsoWired()re-readsOS_SSO_ENABLEDat request time, and better-auth is built lazily, so the two can disagree. If they disagree in the "off" direction, a kernel that mounted SSO would serve discovery with its reads unjudged. That fails open. The built plugin list is the composition that answers the request, so it cannot disagree with itself. The new CONTROL case pins this.Tests
New top-level describe in
sso-discovery-connect-time.test.ts(this file already holds the discovery-scope tests):plugins.sso: false, and forplugins.ssounset withOS_SSO_ENABLEDunset: each ofPOST /sso/register,POST /sign-in/ssoandGET /sso/callback/:providerIdanswers 404.logger.erroris never called, and no warn or info line says "SSO request refused" (6 cases).OS_SSO_ENABLED=true, with the env unset after the build and the context adapter rebuilt as a plain object, still answers 503SERVICE_UNAVAILABLEwith one error line.plugins.sso: true. Those cases stay green, unchanged.Ablation (one-off, no test file kept):
node scripts/ablation-replace.mjsdeleted the anchor&& mountsSsoEndpoints(auth)(anchor 1 to 0, blob b04539afe0af to 739194970b07). The file then had 6 failed and 26 passed: the 6 new 404 cases went red withexpected 503 to be 404, and the existing 503 pins and the CONTROL stayed green. The restore matched the HEAD blob andgit diff HEADwas empty. A first attempt used--replacementwith a substring of the anchor. The tool refused it (replacement count could not rise), so it was a no-op and the test never ran.Acceptance notes
check:dual-build-cjs-loadsexited 3 (PREREQUISITE NOT MET: it needs every package'sdist/, and this container has no room for a full build). NOT MEASURED locally; the PR'sLint & Repo Gatesrun carries it.test:repowas not run locally. The diff touches no file in that project;Test Corecarries it.Verification
All readings were taken at head 1f505ba unless noted.
plugin-auth tests and typecheck
pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2(at 3f7ec3b; the later commit adds only the changeset): Test Files 291 passed (291), Tests 6184 passed and 10 skipped (6194), exit 0.pnpm --filter @objectstack/plugin-auth build && pnpm --filter @objectstack/plugin-auth typecheck: exit 0.check:test-typecheck: OK, 10 files / 71 errors / 23 pinned signatures held in the ledger, unchanged.Derived gate families (dispatch-gates --commands, 76)
pnpm check:dual-build-cjs-loadsexit 3 (PREREQUISITE NOT MET).dispatch-gates --ranwith exit codes recorded: 76 derived families accounted for, 75 run, 1 NOT-MEASURED (derived from the recorded exit 3), 0 UNRUN.Generated by Claude Code