summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/authorization/server.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/authorization/server.rs b/src/authorization/server.rs
index 2605bd54..de7df580 100644
--- a/src/authorization/server.rs
+++ b/src/authorization/server.rs
@@ -9,12 +9,15 @@ pub struct Server {
impl Server {
pub fn new() -> Result<Server, Box<dyn std::error::Error>> {
+ let (_health_reporter, health_service) = tonic_health::server::health_reporter();
+ let authorization_service = AuthorizationServer::with_interceptor(
+ CheckService::new(Arc::new(CedarAuthorizer::default())),
+ logging_interceptor,
+ );
+
Ok(Self::new_with(|mut builder| {
- let (_health_reporter, health_service) = tonic_health::server::health_reporter();
- let authorizer = Arc::new(CedarAuthorizer::default());
- let check_service = CheckService::new(authorizer);
builder
- .add_service(AuthorizationServer::new(check_service))
+ .add_service(authorization_service)
.add_service(health_service)
}))
}
@@ -37,3 +40,8 @@ impl Default for Server {
Self::new().unwrap()
}
}
+
+fn logging_interceptor<T>(request: tonic::Request<T>) -> Result<tonic::Request<T>, tonic::Status> {
+ log::info!("gRPC request received");
+ Ok(request)
+}