From 034cb934375e789a54a22c34b37426ffe9affd4b Mon Sep 17 00:00:00 2001 From: mo khan Date: Wed, 16 Jul 2025 14:09:57 -0600 Subject: fix: revert back to envoy-types crate --- src/authorization/authorizer.rs | 2 +- src/authorization/cedar/authorizer.rs | 12 ++++++------ src/authorization/check_service.rs | 10 ++++++---- src/authorization/default.rs | 2 +- src/authorization/server.rs | 2 +- src/authorization/spice/authorizer.rs | 2 +- 6 files changed, 16 insertions(+), 14 deletions(-) (limited to 'src/authorization') diff --git a/src/authorization/authorizer.rs b/src/authorization/authorizer.rs index 94e44e37..81588a31 100644 --- a/src/authorization/authorizer.rs +++ b/src/authorization/authorizer.rs @@ -1,4 +1,4 @@ -use crate::rpc::envoy::service::auth::v3::CheckRequest; +use envoy_types::pb::envoy::service::auth::v3::CheckRequest; pub trait Authorizer: std::fmt::Debug + std::marker::Sync + std::marker::Send + 'static { fn authorize(&self, request: CheckRequest) -> bool; diff --git a/src/authorization/cedar/authorizer.rs b/src/authorization/cedar/authorizer.rs index dfdf6a80..c7086dd3 100644 --- a/src/authorization/cedar/authorizer.rs +++ b/src/authorization/cedar/authorizer.rs @@ -56,7 +56,7 @@ impl Authorizer { fn map_from( &self, - http_request: crate::rpc::envoy::service::auth::v3::attribute_context::HttpRequest, + http_request: envoy_types::pb::envoy::service::auth::v3::attribute_context::HttpRequest, ) -> Result> { let principal = self.principal_from(&http_request)?; let permission = self.permission_from(&http_request)?; @@ -70,7 +70,7 @@ impl Authorizer { fn principal_from( &self, - http_request: &crate::rpc::envoy::service::auth::v3::attribute_context::HttpRequest, + http_request: &envoy_types::pb::envoy::service::auth::v3::attribute_context::HttpRequest, ) -> Result> { let subject = http_request .headers @@ -85,7 +85,7 @@ impl Authorizer { fn permission_from( &self, - http_request: &crate::rpc::envoy::service::auth::v3::attribute_context::HttpRequest, + http_request: &envoy_types::pb::envoy::service::auth::v3::attribute_context::HttpRequest, ) -> Result> { Ok(cedar_policy::EntityUid::from_type_name_and_id( cedar_policy::EntityTypeName::from_str("Action")?, @@ -95,7 +95,7 @@ impl Authorizer { fn resource_from( &self, - http_request: &crate::rpc::envoy::service::auth::v3::attribute_context::HttpRequest, + http_request: &envoy_types::pb::envoy::service::auth::v3::attribute_context::HttpRequest, ) -> Result> { Ok(cedar_policy::EntityUid::from_type_name_and_id( cedar_policy::EntityTypeName::from_str("Resource")?, @@ -105,7 +105,7 @@ impl Authorizer { fn context_from( &self, - http_request: crate::rpc::envoy::service::auth::v3::attribute_context::HttpRequest, + http_request: envoy_types::pb::envoy::service::auth::v3::attribute_context::HttpRequest, ) -> Result> { let mut items = std::collections::HashMap::new(); @@ -133,7 +133,7 @@ impl Default for Authorizer { } impl crate::authorization::authorizer::Authorizer for Authorizer { - fn authorize(&self, request: crate::rpc::envoy::service::auth::v3::CheckRequest) -> bool { + fn authorize(&self, request: envoy_types::pb::envoy::service::auth::v3::CheckRequest) -> bool { let http_request = match request .attributes .as_ref() diff --git a/src/authorization/check_service.rs b/src/authorization/check_service.rs index 83e6705a..0f29f0b9 100644 --- a/src/authorization/check_service.rs +++ b/src/authorization/check_service.rs @@ -1,4 +1,4 @@ -use crate::rpc::envoy::service::auth::v3::{CheckRequest, CheckResponse}; +use envoy_types::pb::envoy::service::auth::v3::{CheckRequest, CheckResponse}; use std::sync::Arc; use tonic::{Request, Response, Status}; @@ -16,28 +16,30 @@ impl CheckService { } #[tonic::async_trait] -impl crate::rpc::envoy::service::auth::v3::authorization_server::Authorization for CheckService { +impl envoy_types::pb::envoy::service::auth::v3::authorization_server::Authorization for CheckService { async fn check( &self, request: Request, ) -> Result, Status> { if self.authorizer.authorize(request.into_inner()) { Ok(Response::new(CheckResponse { - status: Some(crate::rpc::google::rpc::Status { + status: Some(envoy_types::pb::google::rpc::Status { code: 0, message: "OK".to_string(), details: vec![], }), dynamic_metadata: None, + http_response: None, })) } else { Ok(Response::new(CheckResponse { - status: Some(crate::rpc::google::rpc::Status { + status: Some(envoy_types::pb::google::rpc::Status { code: 7, message: "Unauthorized".to_string(), details: vec![], }), dynamic_metadata: None, + http_response: None, })) } } diff --git a/src/authorization/default.rs b/src/authorization/default.rs index 578ddd4d..5461ca0d 100644 --- a/src/authorization/default.rs +++ b/src/authorization/default.rs @@ -14,7 +14,7 @@ impl Default for Authorizer { } impl super::Authorizer for Authorizer { - fn authorize(&self, _request: crate::rpc::envoy::service::auth::v3::CheckRequest) -> bool { + fn authorize(&self, _request: envoy_types::pb::envoy::service::auth::v3::CheckRequest) -> bool { true } } diff --git a/src/authorization/server.rs b/src/authorization/server.rs index 8546e00f..ba933acd 100644 --- a/src/authorization/server.rs +++ b/src/authorization/server.rs @@ -1,5 +1,5 @@ use super::check_service::CheckService; -use crate::rpc::envoy::service::auth::v3::authorization_server::AuthorizationServer; +use envoy_types::pb::envoy::service::auth::v3::authorization_server::AuthorizationServer; use std::sync::Arc; pub struct Server { diff --git a/src/authorization/spice/authorizer.rs b/src/authorization/spice/authorizer.rs index 57c604bc..79a79c90 100644 --- a/src/authorization/spice/authorizer.rs +++ b/src/authorization/spice/authorizer.rs @@ -8,7 +8,7 @@ impl Authorizer { } impl crate::authorization::authorizer::Authorizer for Authorizer { - fn authorize(&self, _request: crate::rpc::envoy::service::auth::v3::CheckRequest) -> bool { + fn authorize(&self, _request: envoy_types::pb::envoy::service::auth::v3::CheckRequest) -> bool { false } } -- cgit v1.2.3