summaryrefslogtreecommitdiff
path: root/src/authorization/cedar_authorizer.rs
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-05 12:12:56 -0600
committermo khan <mo@mokhan.ca>2025-07-05 12:12:56 -0600
commit836e6658fabdab957ab2ce7be973a5de31247750 (patch)
treeb2f327ce6d68753cedf4e11aee6a13b0a1c13104 /src/authorization/cedar_authorizer.rs
parent2c46c12427c6ae44e6ca96e6cef7522e4435482d (diff)
refactor: provide cedar entities in constructor
Diffstat (limited to 'src/authorization/cedar_authorizer.rs')
-rw-r--r--src/authorization/cedar_authorizer.rs19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/authorization/cedar_authorizer.rs b/src/authorization/cedar_authorizer.rs
index db54aaed..4b697680 100644
--- a/src/authorization/cedar_authorizer.rs
+++ b/src/authorization/cedar_authorizer.rs
@@ -9,14 +9,16 @@ use std::str::FromStr;
#[derive(Debug)]
pub struct CedarAuthorizer {
- policies: PolicySet,
- entities: cedar_policy::Entities,
authorizer: CedarAuth,
+ entities: cedar_policy::Entities,
+ policies: PolicySet,
}
impl CedarAuthorizer {
- pub fn new(policies: cedar_policy::PolicySet) -> CedarAuthorizer {
- let entities = Entities::empty();
+ pub fn new(
+ policies: cedar_policy::PolicySet,
+ entities: cedar_policy::Entities,
+ ) -> CedarAuthorizer {
CedarAuthorizer {
policies,
entities,
@@ -24,8 +26,11 @@ impl CedarAuthorizer {
}
}
- pub fn new_from(path: &std::path::Path) -> CedarAuthorizer {
- Self::new(Self::load_from(path).unwrap_or_else(|_| PolicySet::default()))
+ pub fn new_from(path: &std::path::Path, entities: cedar_policy::Entities) -> CedarAuthorizer {
+ Self::new(
+ Self::load_from(path).unwrap_or_else(|_| PolicySet::default()),
+ entities,
+ )
}
fn load_from(path: &std::path::Path) -> Result<PolicySet, Box<dyn std::error::Error>> {
@@ -130,7 +135,7 @@ impl CedarAuthorizer {
impl Default for CedarAuthorizer {
fn default() -> Self {
- Self::new_from(std::path::Path::new("/etc/authzd"))
+ Self::new_from(std::path::Path::new("/etc/authzd"), Entities::empty())
}
}