Harden central authorization: route inventory, decision table, document revocation (#10) #51

Merged
amiryahaya merged 7 commits from feat/10-central-authorization into main 2026-10-23 06:49:01 +02:00
Owner

Refs #10 (does not close it: two acceptance criteria stay deferred, see below).

What this adds

Test-and-docs hardening of the centralized authorization boundary. No production (non-test) code changes.

  • Route inventory (rag_api::inventory::ROUTES, 31 routes, five protection classes) and crates/api/tests/route_inventory.rs: fails when a mounted route is unclassified, when .nest( / .route_service( / .nest_service( / .fallback( appears in non-test code, or when an enforced route's file does not use the Enforcer. It is a source-text, path-level check; it proves a route is classified and its file uses the Enforcer, not that each handler calls it correctly.
  • Exhaustive decider table (crates/authorization/src/tests/matrix.rs): 8,100 combinations over clearance, compartments, need-to-know, organization, group, action, resource status and policy version. Expected results are hand-written flags from the rules, not computed from the decider; the decider agreed with every combination. It asserts permit or deny, not the denial reason.
  • Real document routes (documents_revocation_postgres, 4 tests): 11 revocation kinds each hide the document on the next request (each with a same-account 200 control); a document with every version revoked, deleted or unavailable is hidden; a lapsed policy gives the same bytes as an absent document; an administrator with only administer, or without the document's group, reads nothing. Shared test helpers moved into common/ as a separate commit (pure move; documents_api 18 and conversations_revocation 6 unchanged).
  • Docs (docs/operations/authorization.md): stale text fixed, route inventory section, and a "Deferred and open" section.

Not closed by this PR

  • Approved environmental conditions: the policy model has none; needs D01-approved semantics.
  • An approved revocation maximum: OD-14 is still proposed; propagation is measured only for account suspension. This PR proves next-request revocation on the real document routes, not a bound.
  • Also recorded as open: issued SearchGrant window, conversation pagination and timing leaks, citations still DenyAllSources, group-forest 10,000-node cap, and Ruling 11 (lapsed policy is the uniform 404 as built, still open).
  • Open for #22: active_attributes returns the latest active version, so revoking only the newest version of a multi-version document would fall back to an older active one; no revoke path exists yet.

Verification (head 6e39233)

cargo fmt --check and cargo clippy --workspace --all-targets --locked -- -D warnings clean; cargo test --workspace --locked 136 passed, 0 failed; bash scripts/test-postgres.sh --local all 13 suites pass (new suite registered there and in scripts/coverage.sh). The coverage script was not run locally; CI will run it.

Synthetic data only; no production, assurance or approval claims.

🤖 Generated with Claude Code

Refs #10 (does not close it: two acceptance criteria stay deferred, see below). ## What this adds Test-and-docs hardening of the centralized authorization boundary. No production (non-test) code changes. - **Route inventory** (`rag_api::inventory::ROUTES`, 31 routes, five protection classes) and `crates/api/tests/route_inventory.rs`: fails when a mounted route is unclassified, when `.nest(` / `.route_service(` / `.nest_service(` / `.fallback(` appears in non-test code, or when an enforced route's file does not use the `Enforcer`. It is a source-text, path-level check; it proves a route is classified and its file uses the `Enforcer`, not that each handler calls it correctly. - **Exhaustive decider table** (`crates/authorization/src/tests/matrix.rs`): 8,100 combinations over clearance, compartments, need-to-know, organization, group, action, resource status and policy version. Expected results are hand-written flags from the rules, not computed from the decider; the decider agreed with every combination. It asserts permit or deny, not the denial reason. - **Real document routes** (`documents_revocation_postgres`, 4 tests): 11 revocation kinds each hide the document on the next request (each with a same-account 200 control); a document with every version revoked, deleted or unavailable is hidden; a lapsed policy gives the same bytes as an absent document; an administrator with only `administer`, or without the document's group, reads nothing. Shared test helpers moved into `common/` as a separate commit (pure move; `documents_api` 18 and `conversations_revocation` 6 unchanged). - **Docs** (`docs/operations/authorization.md`): stale text fixed, route inventory section, and a "Deferred and open" section. ## Not closed by this PR - Approved environmental conditions: the policy model has none; needs D01-approved semantics. - An approved revocation maximum: OD-14 is still `proposed`; propagation is measured only for account suspension. This PR proves next-request revocation on the real document routes, not a bound. - Also recorded as open: issued `SearchGrant` window, conversation pagination and timing leaks, citations still `DenyAllSources`, group-forest 10,000-node cap, and Ruling 11 (lapsed policy is the uniform 404 as built, still open). - Open for #22: `active_attributes` returns the latest active version, so revoking only the newest version of a multi-version document would fall back to an older active one; no revoke path exists yet. ## Verification (head `6e39233`) `cargo fmt --check` and `cargo clippy --workspace --all-targets --locked -- -D warnings` clean; `cargo test --workspace --locked` 136 passed, 0 failed; `bash scripts/test-postgres.sh --local` all 13 suites pass (new suite registered there and in `scripts/coverage.sh`). The coverage script was not run locally; CI will run it. Synthetic data only; no production, assurance or approval claims. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
test(authorization): harden route-inventory scan, add administrator same-account control, fix doc wording (#10)
All checks were successful
CI / Web checks (pull_request) Successful in 1m2s
CI / Web checks (push) Successful in 1m7s
CI / Rust checks (push) Successful in 12m13s
CI / Rust checks (pull_request) Successful in 15m15s
6e39233ce2
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No description provided.