mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 06:03:12 +00:00
2.6 KiB
2.6 KiB
ADR 0001: Work-order media uses single-org scope (board-aligned)
Status
Superseded (2026-08-06) by the SH-221 media slice in PR #47, with fail-closed account scope (follow-up on the same PR):
WorkOrder.AccountId/ApplicationUser.AccountIdschema keys- JWT
account_idwhenApplicationUser.AccountIdis set - JWT
org_scope=allwhen Admin has no AccountId (explicit signed elevation) - Media loads:
ApplyBaseScope+ApplyAccountScope(int)when account-scoped; org-wide path skips account filter - Missing/malformed scope → Forbidden (absence of claim does not elevate)
Board, detail, and search outside media still use base scope only until the remainder of SH-221 lands.
Context (historical)
SH-116 requires that cross-tenant, unauthorized, and out-of-scope media access be rejected without metadata disclosure. An interim Proposed ADR allowed org-wide staff access via absence of an account claim; that path was rejected in review (fail-open) and replaced by the contract below.
Current media contract (superseding)
- Organization boundary =
ApplyBaseScope(non-deleted, non-template). - Account boundary = claim
account_id→WorkOrder.AccountId == claim. - Org-wide = claim
org_scope=allonly (issued to Admin without AccountId). Not inferred from missingaccount_id. - Fail-closed = no valid account or org-scope claim → Forbidden.
- Authorization at service entry: staff roles may read/mutate any resulting
work order; role
Useronly whenAssignTo == actorId; delete staff-only. - User lifecycle persists
AccountIdon create/edit so non-Admin principals can receiveaccount_id.
Consequences
- Cross-account and missing-scope media tests are required.
- Dispatcher/Manager/Supervisor/User without AccountId cannot access media until
AccountId is assigned (or they are Admin with
org_scope=all). - Board/search/detail without account filtering remain a SH-221 follow-up.
Excepted rule
None for media. Hard rule server-derived tenant scope
(ARCHITECTURE_AND_CODE_QUALITY.md §2) is enforced via claims.
Review / expiry
Re-review when SH-221 closes remaining board/search/detail account filters, or by 2027-02-04.
References
- SH-116 — Completion document: fields + media categorization
- SH-221 — Server-derived tenant/customer scope for Work Order domain
- PR: Sea-Haven-Industries/shoc-backend#47
WorkOrderBoardQueryFilters.ApplyBaseScope/ApplyAccountScopeWorkOrderMediaAuthorization/SeaHavenClaimTypesARCHITECTURE_AND_CODE_QUALITY.md§2, §10