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 +++++++----------- src/bin/cli.rs | 2 +- src/lib.rs | 3 ++- 3 files changed, 10 insertions(+), 13 deletions(-) (limited to 'src') 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 diff --git a/src/bin/cli.rs b/src/bin/cli.rs index 5bc118b7..a6d2fa8a 100644 --- a/src/bin/cli.rs +++ b/src/bin/cli.rs @@ -85,7 +85,7 @@ async fn main() -> Result<(), Box> { tracing::info!(address = %addr, "Starting"); authzd::authorization::Server::new( - authzd::authorization::cedar::CedarAuthorizer::default(), + authzd::authorization::cedar::Authorizer::default(), )? .serve(addr.parse().unwrap()) .await?; diff --git a/src/lib.rs b/src/lib.rs index 026d999c..918543dd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,6 @@ pub mod authorization; pub mod gitlab; -pub use authorization::cedar::{CedarAuthorizer, CedarEntity, EntitiesRepository}; +pub use authorization::cedar::{Authorizer as CedarAuthorizer, CedarEntity, EntitiesRepository}; +pub use authorization::spice::Authorizer as SpiceAuthorizer; pub use authorization::{Authorizer, CheckService, Server}; -- cgit v1.2.3