Skip to main content

themis/
lib.rs

1//! Themis: governance and authorization decisions.
2//!
3//! A single engine resolves three access models over the same permission catalog:
4//!
5//! - **RBAC**: roles with inheritance ([`RoleGraph`]) and assignment scoped to a resource
6//!   ([`RoleAssignment`]).
7//! - **ABAC**: serializable conditions over attributes of the subject, the resource and the
8//!   environment ([`Condition`]), with custom functions you can register ([`ConditionRegistry`]).
9//! - **ReBAC**: Zanzibar-style relations ([`RelationSchema`], [`TupleStore`]), used as the
10//!   subject of a grant ([`SubjectMatcher::Relation`]).
11//!
12//! A decision goes through three stages: overrides ([`Override`]), collection of the applicable
13//! grants and combination by a [`Strategy`]. The default strategy ([`MostSpecific`]) lets the most
14//! specific target decide and, within it, `deny` beats `allow`.
15//!
16//! Grant changes and role assignments go through [`Governance`], which applies invariants
17//! (no self-management, no leaving a scope without an administrator, prohibitions) before the
18//! change is persisted and, with the `audit` feature, records each decision in an audit trail
19//! ([`audit`]).
20//!
21//! The crate does no IO and does not depend on an async runtime, and it compiles to WebAssembly.
22//! Real time, caching and transports live in `themis-sync` and the adapters.
23//!
24//! See the [repository README](https://github.com/The-Hades-Organization/Themis) for the full guide.
25
26mod graph;
27
28pub mod attr;
29#[cfg(feature = "audit")]
30pub mod audit;
31pub mod catalog;
32pub mod condition;
33pub mod decision;
34pub mod engine;
35pub mod explain;
36pub mod governance;
37pub mod grant;
38pub mod overrides;
39pub mod rbac;
40pub mod rebac;
41pub mod resource;
42pub mod spec;
43pub mod strategy;
44pub mod subject;
45
46pub use attr::{Attributes, Value};
47#[cfg(feature = "audit")]
48pub use audit::{
49    AuditAction, AuditError, AuditLevel, AuditOutcome, AuditRecord, AuditSink, Auditor, JsonLinesAudit, MemoryAuditLog,
50    RoleChange,
51};
52pub use catalog::{
53    Catalog, CatalogBuilder, CatalogError, CatalogErrors, CatalogExport, CatalogRule, FnRule, PermissionDef,
54    RequireMeta,
55};
56pub use condition::{Condition, ConditionError, ConditionRegistry, EvalContext, Operand};
57pub use decision::{Decision, Reason, Request};
58pub use engine::{CapabilitySet, Context, Engine, EngineBuilder, EngineError, GrantError};
59pub use explain::{
60    ConditionTrace, Explanation, GrantTrace, OverrideOutcome, OverrideStep, TraceResult, Verdict, trace_condition,
61};
62pub use governance::{
63    CatalogConformance, Forbid, Governance, Invariant, Mutation, NoLockout, NoSelfManagement, Proposal,
64    RequirePermission, Violation,
65};
66pub use grant::{Effect, Grant, GrantSource, SubjectMatcher, TargetSelector};
67pub use overrides::{FnOverride, Override, PermissionHolder, ResourceOwner};
68pub use rbac::{RbacError, RoleGraph};
69pub use rebac::{InMemoryTuples, RebacError, RelationSchema, Rewrite, Tuple, TupleStore, TupleSubject};
70pub use resource::{Anchor, GLOBAL, ObjectRef, Resource};
71pub use spec::{
72    EngineSpec, InvariantSpec, OverrideRule, OverrideSpec, RelationSpec, RoleSpec, SpecError, StrategySpec,
73};
74pub use strategy::{Candidate, DenyOverrides, FirstApplicable, MostSpecific, PermitOverrides, Strategy};
75pub use subject::{ANONYMOUS, AUTHENTICATED, RoleAssignment, Subject};