diff options
| -rw-r--r-- | src/authorization/cedar_authorizer.rs | 19 | ||||
| -rw-r--r-- | tests/support/factory_bot.rs | 2 |
2 files changed, 13 insertions, 8 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()) } } diff --git a/tests/support/factory_bot.rs b/tests/support/factory_bot.rs index 15c6f1f3..051b248c 100644 --- a/tests/support/factory_bot.rs +++ b/tests/support/factory_bot.rs @@ -39,7 +39,7 @@ pub fn build_headers(headers: Vec<(String, String)>) -> HashMap<String, String> pub fn build_cedar_authorizer() -> authzd::CedarAuthorizer { let realpath = std::fs::canonicalize("./etc/authzd").unwrap(); let path = realpath.as_path(); - authzd::CedarAuthorizer::new_from(path) + authzd::CedarAuthorizer::new_from(path, cedar_policy::Entities::empty()) } pub async fn build_channel(addr: SocketAddr) -> Channel { |
