id_effect_authz
Authorization for id_effect services. Policies are capabilities:
Principal— who is asking (id, roles, permissions, claims, tenant).id_effect_auth's principals implement it;BasicPrincipalcovers API keys, service accounts and tests. The current one is theCurrentPrincipalcapability, installed per request or job.Policy<Res>— evaluates the principal against a resource as an effect returning aDecision(AlloworDenywith a reason). Combine withand,or,negate,all_of,any_of.- Roles and permissions —
Rbac: role → permission table with inheritance andarea:*wildcards. - Resources — ownership (
owner), tenant match (same_tenant), access lists (Acl,acl_permits). - Attributes — claim predicates (
claim_equals,claim_contains,claim,claim_matches). - Named policies —
Policies, a registry capability;authorize(name, resource)fails withAuthzError(401 for an anonymous principal, 403 otherwise). - Decision events — every decision as a serialisable
DecisionEventdelivered to theAuthzEventssink capability (MemorySink, closures, fan-out). - Route guards (feature
axum) —Guard, a Tower layer evaluating a policy for the request's principal;.authorize(guard)on axum and typed routes; 401/403 as Problem Details. - Test helpers (feature
testing) —AuthzTest::assert_allows/assert_denies/assert_denied_because, with the decisions it recorded.
use ;
use ;
let rbac = builder
.grant
.build;
let policies = builder
.
.build;
type Env = ;
let account = Account ;
let auditor = new;
let stranger = new;
let ok = read.provide_all;
assert_eq!;
let denied = read.provide_all;
assert!;
Examples: cargo run -p id_effect_authz --example 010_policies;
cargo run -p id_effect_authz --example 020_route_guards --features axum,testing. Book: Part VI,
"Authorization".
Tier: platform (ADR 0010 Amendment 5): the Ledger reference app (examples/reference/ledger) depends on it.