summaryrefslogtreecommitdiff
path: root/src/authorization
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-06-27 13:06:08 -0600
committermo khan <mo@mokhan.ca>2025-06-27 13:06:08 -0600
commitc87d86d6e32d58070756883e4e0381d66b9fa1ab (patch)
tree96d2d3c88c4f4442e54dd102d61c742010ec2e16 /src/authorization
parentf59c24589af439e0e22f43a2e42595cf88973ccf (diff)
test: replace hardcoded path with relative path
Diffstat (limited to 'src/authorization')
-rw-r--r--src/authorization/cedar_authorizer.rs10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/authorization/cedar_authorizer.rs b/src/authorization/cedar_authorizer.rs
index 4ec3b34d..c2c594fe 100644
--- a/src/authorization/cedar_authorizer.rs
+++ b/src/authorization/cedar_authorizer.rs
@@ -6,7 +6,6 @@ use cedar_policy::{
use envoy_types::ext_authz::v3::pb::CheckRequest;
use std::collections::HashMap;
use std::fs;
-use std::path::Path;
use std::str::FromStr;
#[derive(Debug)]
@@ -23,12 +22,11 @@ impl CedarAuthorizer {
}
}
- pub fn new_from(dir_path: &str) -> CedarAuthorizer {
- Self::new(Self::load_from(dir_path).unwrap_or_else(|_| PolicySet::default()))
+ pub fn new_from(path: &std::path::Path) -> CedarAuthorizer {
+ Self::new(Self::load_from(path).unwrap_or_else(|_| PolicySet::default()))
}
- fn load_from(dir_path: &str) -> Result<PolicySet, Box<dyn std::error::Error>> {
- let path = Path::new(dir_path);
+ fn load_from(path: &std::path::Path) -> Result<PolicySet, Box<dyn std::error::Error>> {
if !path.exists() || !path.is_dir() {
return Ok(PolicySet::default());
}
@@ -55,7 +53,7 @@ impl CedarAuthorizer {
}
impl Default for CedarAuthorizer {
fn default() -> Self {
- Self::new_from("/etc/authzd")
+ Self::new_from(fs::canonicalize("/etc/authzd").unwrap().as_path())
}
}