Add typed security and authorization contracts #38

Merged
amiryahaya merged 1 commit from feat/7-security-contracts into main 2026-10-21 21:19:26 +02:00
Owner

Summary

Replace raw security attributes and the incomplete policy skeleton with typed, default-deny contracts for future identity/storage/retrieval adapters. Refs #7.

rag-domain          validated IDs, markings, configured ranks, validity, actions
rag-authorization   verified subject + current policy + server request context
                    ├── resource permit/deny
                    └── immutable request-scoped search constraints

Missing organization now denies instead of behaving as unrestricted scope. Classification has no lexical ordering; policy ranks are authoritative. Subject and policy must both grant the action. Source markings, policy versions and lifecycle status are checked before content permission. Scopes expire at the earliest identity/policy/request deadline and reject another request, cancellation or stale context.

Only trusted authorization code can construct subjects/scopes; compile-fail checks guard private promotion, JSON deserialization and typed identifiers. SQL/Qdrant adapters must apply every filter and still reauthorize current canonical metadata before loading text. Organization/tenant scope is one mandatory exact partition; broader access needs an approved extension.

Evidence

  • Before: control-bearing classification input was accepted; the added malformed-label test failed. New authorization tests failed against deny-only interface stubs before behavior implementation.
    After: 17 behavioral test functions (including shared permit/deny matrices) and six compile-fail checks pass.
  • cargo fmt --all -- --check — pass.
  • cargo clippy --workspace --all-targets --locked -- -D warnings — pass.
  • cargo test --workspace --locked — pass, including shared adapter contracts for ranks, all required grants, lifecycle, policy/freshness, scope constraints, expiry and ownership.
  • npm run typecheck and npm run build — pass.
  • Independent security review found no current bypass/correctness defect. Its shared-suite coverage finding was addressed by moving all existing rank/scope/grant invariants behind &dyn PolicyDecider helpers used by the shared suite.
  • Hosted CI passed for head 1ec1176ad5114d169cc152d4df41e8bc00232581: push run #4 and PR run #5. Both Rust and web jobs succeeded.

Merge Danger

Door: two-way

Blast Radius: authorization

Changes domain/policy interfaces before their storage/identity consumers are built. API/UI behavior is unchanged. Production identity, authoritative revocation and real database/vector filters remain subsequent issues. Adds only an existing workspace dependency as a dev dependency for JSON compile-fail guards; no new runtime dependency. Issue #7 remains open pending review/merge.

## Summary Replace raw security attributes and the incomplete policy skeleton with typed, default-deny contracts for future identity/storage/retrieval adapters. Refs #7. ```text rag-domain validated IDs, markings, configured ranks, validity, actions rag-authorization verified subject + current policy + server request context ├── resource permit/deny └── immutable request-scoped search constraints ``` Missing organization now denies instead of behaving as unrestricted scope. Classification has no lexical ordering; policy ranks are authoritative. Subject and policy must both grant the action. Source markings, policy versions and lifecycle status are checked before content permission. Scopes expire at the earliest identity/policy/request deadline and reject another request, cancellation or stale context. Only trusted authorization code can construct subjects/scopes; compile-fail checks guard private promotion, JSON deserialization and typed identifiers. SQL/Qdrant adapters must apply every filter and still reauthorize current canonical metadata before loading text. Organization/tenant scope is one mandatory exact partition; broader access needs an approved extension. ## Evidence - **Before:** control-bearing classification input was accepted; the added malformed-label test failed. New authorization tests failed against deny-only interface stubs before behavior implementation. **After:** 17 behavioral test functions (including shared permit/deny matrices) and six compile-fail checks pass. - `cargo fmt --all -- --check` — pass. - `cargo clippy --workspace --all-targets --locked -- -D warnings` — pass. - `cargo test --workspace --locked` — pass, including shared adapter contracts for ranks, all required grants, lifecycle, policy/freshness, scope constraints, expiry and ownership. - `npm run typecheck` and `npm run build` — pass. - Independent security review found no current bypass/correctness defect. Its shared-suite coverage finding was addressed by moving all existing rank/scope/grant invariants behind `&dyn PolicyDecider` helpers used by the shared suite. - Hosted CI passed for head `1ec1176ad5114d169cc152d4df41e8bc00232581`: [push run #4](https://forgejo.primatekun.tech/primatekuntech/rag-rust/actions/runs/4) and [PR run #5](https://forgejo.primatekun.tech/primatekuntech/rag-rust/actions/runs/5). Both Rust and web jobs succeeded. ## Merge Danger **Door:** two-way **Blast Radius:** authorization Changes domain/policy interfaces before their storage/identity consumers are built. API/UI behavior is unchanged. Production identity, authoritative revocation and real database/vector filters remain subsequent issues. Adds only an existing workspace dependency as a dev dependency for JSON compile-fail guards; no new runtime dependency. Issue #7 remains open pending review/merge.
feat: define typed security and authorization contracts
All checks were successful
CI / Web checks (push) Successful in 34s
CI / Web checks (pull_request) Successful in 21s
CI / Rust checks (push) Successful in 1m31s
CI / Rust checks (pull_request) Successful in 1m28s
1ec1176ad5
Issue policy-owned request-scoped search constraints, validate security identifiers and validity windows, and enforce current ranks, grants, organization, lifecycle and policy versions. Add shared adapter contracts and compile-time capability guards.

Refs #7
amiryahaya changed title from WIP: Add typed security and authorization contracts to Add typed security and authorization contracts 2026-10-21 21:19:17 +02:00
Sign in to join this conversation.
No description provided.