Skip to main content

olai_datafusion_policy_cedar/
lib.rs

1//! Cedar adapter for the engine-neutral policy layer ([`datafusion-policy`]).
2//!
3//! The neutral crate ([`datafusion_policy`]) owns the decide/enforce split — the
4//! [`PolicyEngine`] trait, the [`PolicyQueryPlanner`] enforcement hook, the plan
5//! rewrite, and all neutral types. This crate is one **adapter** behind that
6//! seam: it implements [`PolicyEngine`] with Cedar
7//! ([`CedarPolicyEngine`]), lowers the neutral principal to Cedar entities
8//! ([`principal_entities`]), lowers the neutral plan-action list to Cedar
9//! authorization requests, and reads Cedar partial-eval residuals into
10//! DataFusion predicates ([`CedarResidualTranslator`]). Policy *sourcing*
11//! (pulling a policy set / schema / entities from an OCI registry) lives in the
12//! [`cedar-oci`](https://docs.rs/olai-cedar-oci) crate; engine-specific *glue*
13//! (extracting the principal from a request, composing onto a session) lives in
14//! the host — see [hydrofoil](https://github.com/open-lakehouse/hydrofoil) for a
15//! reference host.
16//!
17//! The neutral core's public surface ([`PolicyEngine`], [`PrincipalIdentity`],
18//! [`PolicyExtension`], …) is re-exported here so a Cedar host has a single
19//! import surface.
20//!
21//! [`datafusion-policy`]: datafusion_policy
22
23mod cedar;
24mod cedar_entity;
25mod visitor;
26
27#[cfg(feature = "fgac")]
28mod translate;
29
30pub use cedar::{CedarPolicyEngine, InMemoryPolicyProvider};
31pub use cedar_entity::{parse_uid, principal_entities};
32
33// Re-export the neutral core's public surface so a Cedar host imports one crate.
34pub use datafusion_policy::{
35    AgentClaims, AttrValue, CatalogFactSink, CatalogFactSinkExt, ConstraintTranslator, Decision,
36    EvalContext, EvalContextProvider, Governance, GovernanceBuilder, Group, IdentityError,
37    IdentityProvider, PlanAction, PolicyBuilder, PolicyEngine, PolicyExtension, PolicyQueryPlanner,
38    PolicySessionExt, Posture, PrincipalClaims, PrincipalEnrichment, PrincipalExt,
39    PrincipalIdentity, PrincipalProvider, SessionConfigEvalContextProvider,
40    SessionConfigPrincipalProvider, StaticPolicyEngine, TableFacts, authorize_and_govern,
41    authorize_and_govern_with_posture, instrument_session_state, normalize, plan_actions,
42};
43
44#[cfg(feature = "fgac")]
45pub use datafusion_policy::{
46    AbacPolicyEngine, BindingKind, CatalogFunctionResolver, ColumnMatch, DefaultPrincipalMatcher,
47    FactStore, FactStoreExt, FunctionArg, FunctionResolverExt, InMemoryFactStore, PolicyBinding,
48    PrincipalMatcher, TablePolicy, TagCondition, govern_plan,
49};
50#[cfg(feature = "fgac")]
51pub use translate::CedarResidualTranslator;
52
53// Re-export the cedar identity types through this crate so consumers building
54// Cedar-shaped principals/requests directly have a single import surface (they
55// originate in `cedar-oci`).
56pub use cedar_oci::{EntityId, EntityTypeName, EntityUid};
57
58// Cedar value/entity types a host may need to build Cedar requests directly
59// (the neutral principal is lowered via [`principal_entities`]).
60pub use cedar_policy::{Entity, RestrictedExpression};
61
62// Cedar provider traits a [`CedarPolicyEngine`] is generic over, re-exported for
63// consumers building an authorizer.
64pub use cedar_local_agent::public::{SimpleEntityProvider, SimplePolicySetProvider};