summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-16 11:00:38 -0600
committermo khan <mo@mokhan.ca>2025-07-16 11:00:38 -0600
commitd04d2e530baad1470736a601dfcafd4162952ae4 (patch)
tree0010865ce965374be699b25aef1b008fc6bf0ace /src
parentfb05a439113daf8750be6df025f9676221d8e228 (diff)
refactor: rename CedarAuthorizer to cedar::Authorizer
Diffstat (limited to 'src')
-rw-r--r--src/authorization/cedar/authorizer.rs18
-rw-r--r--src/bin/cli.rs2
-rw-r--r--src/lib.rs3
3 files changed, 10 insertions, 13 deletions
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<dyn std::error::Error>> {
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};