From 836e6658fabdab957ab2ce7be973a5de31247750 Mon Sep 17 00:00:00 2001 From: mo khan Date: Sat, 5 Jul 2025 12:12:56 -0600 Subject: refactor: provide cedar entities in constructor --- src/authorization/cedar_authorizer.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/authorization') 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> { @@ -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()) } } -- cgit v1.2.3