summaryrefslogtreecommitdiff
path: root/src/authorization
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2025-07-16 14:09:57 -0600
committermo khan <mo@mokhan.ca>2025-07-16 14:09:57 -0600
commit034cb934375e789a54a22c34b37426ffe9affd4b (patch)
treeed82d15f8c9dbad06b9932fc43acafae531b94f8 /src/authorization
parentaadfbeb39d0ac5ccb1a19899d7680b1c96b1a6cf (diff)
fix: revert back to envoy-types crate
Diffstat (limited to 'src/authorization')
-rw-r--r--src/authorization/authorizer.rs2
-rw-r--r--src/authorization/cedar/authorizer.rs12
-rw-r--r--src/authorization/check_service.rs10
-rw-r--r--src/authorization/default.rs2
-rw-r--r--src/authorization/server.rs2
-rw-r--r--src/authorization/spice/authorizer.rs2
6 files changed, 16 insertions, 14 deletions
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<cedar_policy::Request, Box<dyn std::error::Error>> {
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<cedar_policy::EntityUid, Box<dyn std::error::Error>> {
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<cedar_policy::EntityUid, Box<dyn std::error::Error>> {
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<cedar_policy::EntityUid, Box<dyn std::error::Error>> {
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<cedar_policy::Context, Box<dyn std::error::Error>> {
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<CheckRequest>,
) -> Result<Response<CheckResponse>, 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
}
}