Self-hosted relationship-based authorization (ReBAC) over a Corium
database.
corium-protocol's Authorizer seam
was built so a deployment could point authorization at an external policy
service. This crate is the answer for deployments that would rather not run
one: Corium's own data model — entities, reference attributes, immutable
history — is a good fit for the tuple shape ReBAC needs, so the policy
lives in an ordinary Corium database and the check is a bounded in-memory
graph walk over a compiled snapshot of it.
Check(subject, action, object, database, at_authz_t)
action -> required relation(s) (permission map)
subject --relation/derived--> object (tuples + rewrites)
optional binding -> ViewFilter (bindings + views)
The pieces
- [
schema] — the reserved attributes of the authz database, and the EDN an operator installs to create one. - [
model] — the policy vocabulary: objects, tuples, permissions, rewrites, views, bindings. Relation names are data, not Rust enums. - [
policy::Policy] — an immutable compiled snapshot keyed by the authz database's basist, with the indexes a check needs. - [
eval] — the bounded, cycle-safe relationship search. - [
subject] — how a requestPrincipalbecomes the subjects the search starts from. - [
source::PolicySource] — where snapshots come from; each surface supplies the database value it already holds. - [
SystemDbAuthorizer] — theAuthorizeritself: snapshot caching, consistency, result caching, fail-closed behaviour, break-glass, audit. - [
bootstrap] — building an authz database in process, and the EDN an operator's grant/revoke sends to a real one.
Fail closed
Every failure that leaves the authorizer without a policy — a missing authz
database, an unreadable snapshot, a policy that does not compile — denies.
The one exception is an explicit [BreakGlass] configuration for operator
recovery, and it is audited at warn every time it grants. A snapshot that
stops compiling never replaces the last good one either: the process
keeps deciding from the policy it already has.
Example
use Arc;
use ;
use ;
#
# async