From d04d2e530baad1470736a601dfcafd4162952ae4 Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 16 Jul 2025 11:00:38 -0600 Subject: refactor: rename CedarAuthorizer to cedar::Authorizer --- src/authorization/cedar/authorizer.rs | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/authorization/cedar') diff --git a/src/authorization/cedar/authorizer.rs b/src/authorization/cedar/authorizer.rs index c207467f..a04a8e9f 100644 --- a/src/authorization/cedar/authorizer.rs +++ b/src/authorization/cedar/authorizer.rs @@ -1,27 +1,23 @@ -use crate::authorization::authorizer::Authorizer; use std::fs; use std::str::FromStr; #[derive(Debug)] -pub struct CedarAuthorizer { +pub struct Authorizer { authorizer: cedar_policy::Authorizer, entities: cedar_policy::Entities, policies: cedar_policy::PolicySet, } -impl CedarAuthorizer { - pub fn new( - policies: cedar_policy::PolicySet, - entities: cedar_policy::Entities, - ) -> CedarAuthorizer { - CedarAuthorizer { +impl Authorizer { + pub fn new(policies: cedar_policy::PolicySet, entities: cedar_policy::Entities) -> Authorizer { + Authorizer { policies, entities, authorizer: cedar_policy::Authorizer::new(), } } - pub fn new_from(path: &std::path::Path, entities: cedar_policy::Entities) -> CedarAuthorizer { + pub fn new_from(path: &std::path::Path, entities: cedar_policy::Entities) -> Authorizer { Self::new( Self::load_from(path).unwrap_or_else(|e| { tracing::error!( @@ -127,7 +123,7 @@ impl CedarAuthorizer { } } -impl Default for CedarAuthorizer { +impl Default for Authorizer { fn default() -> Self { Self::new_from( std::path::Path::new("./etc/authzd"), @@ -136,7 +132,7 @@ impl Default for CedarAuthorizer { } } -impl Authorizer for CedarAuthorizer { +impl crate::authorization::authorizer::Authorizer for Authorizer { fn authorize(&self, request: envoy_types::ext_authz::v3::pb::CheckRequest) -> bool { let http_request = match request .attributes -- cgit v1.2.3