feat(console): per-tenant ledger read scoping (RBAC + tenant_id column)#4
Closed
New1Direction wants to merge 1 commit into
Closed
feat(console): per-tenant ledger read scoping (RBAC + tenant_id column)#4New1Direction wants to merge 1 commit into
New1Direction wants to merge 1 commit into
Conversation
Completes the authZ half of the console finding (PR #3 closed the authN hole). - auth_guard.tenant_scope: derives the read filter from JWT claims — admins (and the dev opt-out) read across tenants; a non-admin is restricted to its own tenant_id; a token with no tenant_id claim is 403 (cannot be scoped). - ledger_router: /traces, /trace/{id}, /summary now filter by the caller's tenant, so one tenant can never read another's traces (cross-tenant id -> 404). - ExecutionTrace gains tenant_id (default 'default'); StateLedger persists it and migrates legacy DBs in place (ALTER ADD COLUMN). Excluded from the state hash. FOLLOW-UP: thread the real request tenant into orchestrator-written traces (the execution path is currently tenant-blind, so those rows persist as 'default'). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Owner
Author
|
Consolidated. All commits from this PR are now in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes the authorization half of the console finding. Stacked on #3 (which closed the unauthenticated-access hole); base is
fix/critical-security-3.What this adds
auth_guard.tenant_scope— derives the ledger read filter from the authenticated principal:adminrole (and the explicit dev opt-out) → read across all tenants;tenant_id;tenant_idclaim →403(can't be scoped safely).ledger_router—/traces,/trace/{id},/summarynow filter by the caller's tenant. One tenant can no longer see another's traces (a cross-tenant id resolves to404).ExecutionTracegainstenant_id(default"default");StateLedgerpersists it and migrates legacy DBs in place (ALTER TABLE ADD COLUMN). It is metadata only — excluded from the content-addressed state hash, so determinism is unaffected.Verification
test_ledger_tenant_scope.py(read isolation: own-tenant only / cross-tenant 404 / admin sees all / no-tenant 403) +test_ledger_tenant.py(persist + legacy migration + default).ruff check+format --check: clean.Honest follow-up (not in this PR)
The orchestrator write-path is tenant-blind — it has no request context, so traces it writes persist as
tenant_id = "default". Read-side isolation is fully enforced here; threading the real request tenant into those writes is a separate change (needs tenant context plumbed through the execution path).🤖 Generated with Claude Code