1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! # Cedar ABAC Module for PEP
//!
//! This module integrates AWS Cedar as a fine-grained, attribute-based access
//! control (ABAC) engine into the PEP library. It provides:
//!
//! - **`CedarAuthorizer`**: Loads Cedar policies and evaluates authorization requests
//! - **`CedarConfig`**: TOML-based configuration for policy paths and settings
//! - **`PolicyStoreClient`**: Fetches policies from a remote HTTP endpoint
//! - **`PolicyStoreResponse`**: Wire format for the policy store API
//! - **`SchemaLoader`**: Loads Cedar schemas from `.cedarschema` files
//! - **Entity building**: Converts `JwtClaims` and resource metadata into Cedar entities
//!
//! Cedar sits after PEP's JWT authentication layer:
//!
//! ```text
//! Request → PEP (JWT validation) → Cedar (authorization) → Handler (data)
//! "Who are you?" "Can you do this?" "Here's the data"
//! ```
//!
//! # Policy Sources
//!
//! `CedarAuthorizer` supports three policy sources, tried in priority order:
//!
//! 1. **Policy store URL** — fetched from a remote HTTP endpoint (e.g. PDT `/api/cedar/policies`)
//! 2. **Filesystem** — loaded from `policy_path` on disk
//! 3. **Embedded** — compiled into the binary via `include_str!` as a default
//!
//! # Example: Embedded defaults with remote policy store
//!
//! ```rust,ignore
//! use pep::cedar::{CedarAuthorizer, CedarConfig};
//!
//! let config = CedarConfig {
//! policy_path: "./policies".into(), // filesystem fallback
//! embedded_policy: Some(include_str!("../policies/rbac.cedar")),
//! embedded_schema: Some(include_str!("../policies/schema.cedarschema")),
//! policy_store_url: Some("http://localhost:8080/api/cedar/policies".into()),
//! ..Default::default()
//! };
//! let authorizer = CedarAuthorizer::new_with_policy_store(config).await?;
//! ```
pub use CedarAuthorizer;
pub use ;
pub use ;
pub use CedarError;
pub use ;
pub use ;