Repository navigation
fix(rest): a door whose environment's security service cannot be resolved refuses rather than proceeds - #31404
Conversation
…lved refuses rather than proceeds The server's security resolver keeps two answers apart by the registry's own "never registered" brand: a security service that is not registered still answers `undefined` (no permission posture, ADR-0106 D6 tier 1), and every other rejection raises AuthzStoreUnavailableError, the door's 503 SERVICE_UNAVAILABLE (ADR-0106 D6 tier 3; ADR-0049). Pinned on the hosted multi-environment shape, both mounts: the export, the import template's gate, the template's column projection and the object-schema mask refuse for a security slot registered as a throwing factory and for an acquisition rejecting at the security step, beside a healthy control, an environment with no security service and a single kernel with none (both unchanged), and an environment no acquisition reaches (still refused before any door serves). Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
…be resolved refuses rather than proceeds Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
…ity-unresolved-refuses
…rity-posture test files Both files reach the route modules' lazy `@objectstack/objectql` import; the module-top side-effect import keeps that load out of every clocked case (`check:test-source-alias`, the source reach). Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 12 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 8 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 19 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 f7cea3943a3f60181ec0a9bc4e35ac515d23b965 && git checkout f7cea3943a3f60181ec0a9bc4e35ac515d23b965
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 216b18a6ccb47dc23d3fe9f6a8575daf54f25dd5 a657a718b8f41699a636698e0e271b4904201b17 && git checkout -B drift-repro 216b18a6ccb47dc23d3fe9f6a8575daf54f25dd5 && git merge --no-ff a657a718b8f41699a636698e0e271b4904201b17
node scripts/docs-audit/affected-docs.mjs --json 216b18a6ccb47dc23d3fe9f6a8575daf54f25dd5
|
…ity-unresolved-refuses
…use when the environment's security service cannot be resolved The access-explanation family and the suggested-binding family ask the server's one security resolver instead of their own, so a security service that is not registered keeps each family's 501 and any other rejection answers 503 SERVICE_UNAVAILABLE through each family's emitter. The record page resolves the explain part's security service inside each operation's own try, after the caller check, so the part carries the 503 as its own refusal and the page still answers. Pinned on the hosted rig, both mounts: the record page (explain and field-access parts), the access explanation and the suggested bindings, for a throwing factory and for an acquisition rejecting at the security step, beside a healthy control and a never-registered control. Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
…ecurity family's 503 Each family's envelope test drives its doors with a security provider that rejects and with a caller context whose authorization store cannot be read (both 503 SERVICE_UNAVAILABLE in the nested envelope), and with the registry's own never-registered rejection from a real kernel (the 501 stays). Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
…environment's security service cannot be resolved Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
…ity-unresolved-refuses
Both families' resolvers now ask the server's resolver, whose return is the narrower partial service; annotating each `resolveService` with the provider's own answer type keeps the bodies typed exactly as they were. Type-only: nothing is emitted differently. Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
…very reader of the slot Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f Co-authored-by: Claude <noreply@anthropic.com>
|
security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f 席位核对ACCEPT at
Implemented-by: os-dev (security#1 order, |
Clause-②: no
Metadata-protocol: none
维护者速读
/security各门照旧答 501);注册了但解析不出来 ⇒ 答 503 SERVICE_UNAVAILABLE,什么都不提供。/security各门答 503;记录页照常返回,只有 explain 与 fieldAccess 两个分片各自带 503。没装 plugin-security、或单内核没有 security 服务的部署行为不变(已钉测试)。回滚 = revert 本 PR。packages/rest/src/rest-server.ts的resolveSecurityService(核心分类,catch 分支 4 行);②packages/rest/src/security-routes.ts(两个族改走同一解析器,各自 catch 增加 503 分支);③packages/rest/src/record-page-routes.ts的answerExplain(解析挪进每个操作自己的 try)。pnpm --filter @objectstack/rest exec vitest run --project local --maxWorkers=2 src/rest-environment-scoped-providers.test.ts src/rest-export-permission-gate.test.ts src/security-explain-envelope.test.ts src/security-suggested-bindings-envelope.test.ts src/rest-server-suggested-bindings-status.test.ts,预期 5 个文件、225 个用例全绿。What changes
Rule: a door whose environment's security service cannot be resolved refuses rather than proceeds.
RestServer.resolveSecurityServicekeeps the two answers thesecurityslot can give apart, by the service registry's own "never registered" brand (isServiceNotRegisteredError), never by message text:undefined: no provider is wired, the environment's kernel registers nosecurityservice, or the branded rejection reaches the resolver. The deployment has no permission posture (ADR-0106 D6 tier 1), and every caller keeps its documented degradation for that case, the/securitydoors'501 NOT_IMPLEMENTEDincluded.AuthzStoreUnavailableError('security', cause), answered as503 SERVICE_UNAVAILABLE(ADR-0106 D6 tier 3; ADR-0049). No error code, envelope key or public export is added.The doors listed in the table below ask this one resolver. The access-explanation family and the suggested-binding family in
security-routes.tshand their reads to it through their route hosts instead of carrying their own; each family'scatchanswers the outage as the data door's own503 SERVICE_UNAVAILABLE(mapDataError, message withheld as every 5xx there is) through the family's one emitter. The record page resolves the explain part's security service once, inside each operation's owntryand after the caller check (the order/security/explainasks in), so the part carries the refusal and the page still answers. This is the same classification the anonymous form doors' tenancy read already makes. The environment-scoped provider inrest-api-plugin.tsis unchanged.Measured on the hosted multi-environment shape (the first six rows and the explain door and suggested bindings), in each security family's envelope test (the delegable scope, confirm, dismiss and reopen), and by a one-off probe on
b7ef72106for the effective-access door (503/501/ healthy200), which no test drives:GET …/data/:object/export503, no row read, nothing writtenGET …/data/:object/export?template=true, its gate503, no template503, no templatenone, as beforeGET …/meta/object/:name(object-schema mask, on by default)503, no schemaGET …/data/:object/:id/field-access503501, as beforePOST …/data/:object/:id/page,explainandfieldAccessparts503; the page answers200with the record501, as beforeGET/POST …/security/explain,…/security/my-delegable-scope,…/security/users/:id/effective-access503(nested envelope)501, as before…/security/suggested-bindings, its confirm, dismiss and reopen503(nested envelope)501, as beforeDocblocks of the resolver, the export gate, the import-template gate, the object masker, both security families and the record page's explain part state the rule.
Tests
packages/rest/src/rest-environment-scoped-providers.test.ts, two top-level describes on the existing hosted rig (realObjectKernels behind one REST plugin), each case on both the scoped and the hostname mount:503 SERVICE_UNAVAILABLEand serve nothing; the template's column projection refuses when its own security step cannot be resolved after the gate answered; the record page still answers, its explain and field-access parts each carrying the503; the access explanation and the suggested bindings refuse with503. Controls in the same describe: a healthy service (export403 EXPORT_NOT_PERMITTED, template403 PERMISSION_DENIED, projectionwritable, schema masked, explain part and both/securitydoors answered by the environment's service); an environment with no security service (every door serves, projectionnone, schema unmasked, the explain part and both/securitydoors501); an environment no acquisition reaches (still refused before any door serves); and the resolver still answeringundefinedwhere nothing is registered.packages/rest/src/rest-export-permission-gate.test.ts: a wired provider that rejects answers503 SERVICE_UNAVAILABLEwith nothing read; a provider rejecting with the registry's own "never registered" rejection (from a real kernel, asserted branded) is allowed, exactly as no security service at all.packages/rest/src/security-explain-envelope.test.tsandpackages/rest/src/security-suggested-bindings-envelope.test.ts, one describe each, in the family's nested envelope: a security provider that rejects answers503 SERVICE_UNAVAILABLEon every route; a caller context whose authorization store cannot be read answers the same503, and the service is never asked; the registry's "never registered" rejection keeps the501.Acceptance notes
AuthzStoreUnavailableErrorreaching theircatch, so a caller context whose authorization store cannot be read answers these doors503 SERVICE_UNAVAILABLE. Same rule, same family emitters; pinned in both envelope test files.Verification
Final head
b7ef72106(origin/mainmerged in atf90cb94fbandb5a46e2aa; the rest dependency closure rebuilt after the first). Each reading names the head it was taken on.Ablations of the server's resolver (round 1, on 40711ac)
Through
scripts/ablation-replace.mjs: anchor hit as declared, blob changed, restore proven each time (blob equals HEAD's,git diff HEADempty). The subject resolves through relativesrcimports, so no build sits between mutation and run.Ablations of round 2
a77a0c67a, the explain part's resolution put back before the loop, outside the per-operation try: 4 red, 143 green of 147, exactly the record-page legs for the two unresolvable environments on both mounts. Restored.a77a0c67a, both security families' resolvers made to swallow the rejection: 4 red, 143 green of 147, exactly the access-explanation and suggested-binding legs for the two unresolvable environments on both mounts. Restored.cbc8eeaf8, both families' outage arms disabled: 4 red, 58 green of 62, exactly the four outage pins in the two envelope files. Restored. A first attempt is void and not counted: its replacement inverted the explain helper's guard instead of disabling it, so four unrelated500-arm cases went red too.b7ef72106after these adds only a type annotation to the two families' resolvers (nothing emitted differently).Suites and typecheck
pnpm --filter @objectstack/rest testonb7ef72106: 394 files passed, 7538 tests passed, 332 skipped; lock verdictcommand-exit 0.b7ef72106: 5 files, 225 tests passed.pnpm --filter @objectstack/rest typecheck(tsc plus the test-layer typecheck) onb7ef72106:command-exit 0;tsc -p tsconfig.test.json --listFilesOnlylists all four edited test files, and the debt ledger holds 0 files.test:repo(the package'srepovitest project) is not run locally: this diff edits none of its files; CI's Test Core runs it.Derived gates
node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstackonb7ef72106: 71 commands (49 pnpm, 22 node), each run with its exit code captured before any pipe: 70 exit 0;check:dual-build-cjs-loadsanswered PREREQUISITE NOT MET (exit 3) at its place in the run, before a later gate had built the remaining packages, and exit 0 when re-run after the run.--ranreconciliation on the same head: 71 derived, 71 run, 0 NOT-MEASURED, 0 UNRUN, a derived zero (every line carries its exit code; the re-run's for that one gate).Written for the security#1 seat (security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f) by its os-dev executor.