summaryrefslogtreecommitdiff
path: root/src/authorization
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-05 12:18:58 -0600
committermo khan <mo@mokhan.ca>2025-07-05 12:18:58 -0600
commit3b6b2b3029e0b9ba185028db0eb77a3d46998a5c (patch)
treefab0483e5b122dfa9c2675f131f6cf15082fd637 /src/authorization
parenta9be59c733e63b57bf872bdc82495a6d93308577 (diff)
refactor: inline cedar policy namespace
Diffstat (limited to 'src/authorization')
-rw-r--r--src/authorization/cedar_authorizer.rs28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/authorization/cedar_authorizer.rs b/src/authorization/cedar_authorizer.rs
index 5fe0dd64..6b901e5d 100644
--- a/src/authorization/cedar_authorizer.rs
+++ b/src/authorization/cedar_authorizer.rs
@@ -1,5 +1,4 @@
use super::authorizer::Authorizer;
-use cedar_policy::{Context, Entities, EntityId, EntityTypeName, EntityUid};
use std::fs;
use std::str::FromStr;
@@ -73,9 +72,9 @@ impl CedarAuthorizer {
&self,
_http_request: &envoy_types::pb::envoy::service::auth::v3::attribute_context::HttpRequest,
) -> Result<cedar_policy::EntityUid, Box<dyn std::error::Error>> {
- Ok(EntityUid::from_type_name_and_id(
- EntityTypeName::from_str("User")?,
- EntityId::from_str("client")?,
+ Ok(cedar_policy::EntityUid::from_type_name_and_id(
+ cedar_policy::EntityTypeName::from_str("User")?,
+ cedar_policy::EntityId::from_str("client")?,
))
}
@@ -83,9 +82,9 @@ impl CedarAuthorizer {
&self,
_http_request: &envoy_types::pb::envoy::service::auth::v3::attribute_context::HttpRequest,
) -> Result<cedar_policy::EntityUid, Box<dyn std::error::Error>> {
- Ok(EntityUid::from_type_name_and_id(
- EntityTypeName::from_str("Action")?,
- EntityId::from_str("check")?,
+ Ok(cedar_policy::EntityUid::from_type_name_and_id(
+ cedar_policy::EntityTypeName::from_str("Action")?,
+ cedar_policy::EntityId::from_str("check")?,
))
}
@@ -93,9 +92,9 @@ impl CedarAuthorizer {
&self,
_http_request: &envoy_types::pb::envoy::service::auth::v3::attribute_context::HttpRequest,
) -> Result<cedar_policy::EntityUid, Box<dyn std::error::Error>> {
- Ok(EntityUid::from_type_name_and_id(
- EntityTypeName::from_str("Resource")?,
- EntityId::from_str("resource")?,
+ Ok(cedar_policy::EntityUid::from_type_name_and_id(
+ cedar_policy::EntityTypeName::from_str("Resource")?,
+ cedar_policy::EntityId::from_str("resource")?,
))
}
@@ -110,7 +109,9 @@ impl CedarAuthorizer {
items.insert("method".to_string(), self.safe_string(&http_request.method));
items.insert("path".to_string(), self.safe_string(&http_request.path));
- Ok(Context::from_pairs(items.into_iter().collect::<Vec<_>>())?)
+ Ok(cedar_policy::Context::from_pairs(
+ items.into_iter().collect::<Vec<_>>(),
+ )?)
}
fn token_from(
@@ -133,7 +134,10 @@ impl CedarAuthorizer {
impl Default for CedarAuthorizer {
fn default() -> Self {
- Self::new_from(std::path::Path::new("/etc/authzd"), Entities::empty())
+ Self::new_from(
+ std::path::Path::new("/etc/authzd"),
+ cedar_policy::Entities::empty(),
+ )
}
}