diff --git a/jwt-authorizer/src/error.rs b/jwt-authorizer/src/error.rs index 6cf663f..ad9bf4b 100644 --- a/jwt-authorizer/src/error.rs +++ b/jwt-authorizer/src/error.rs @@ -116,6 +116,10 @@ impl From for Response { debug!("AuthErrors::InvalidClaims"); tonic::Status::unauthenticated("error=\"insufficient_scope\"") } + AuthError::NoAuthorizer() => { + debug!("AuthErrors::NoAuthorizer"); + tonic::Status::unauthenticated("error=\"invalid_token\"") + } } .to_http() } diff --git a/jwt-authorizer/tests/tonic.rs b/jwt-authorizer/tests/tonic.rs index ac8874b..4d71863 100644 --- a/jwt-authorizer/tests/tonic.rs +++ b/jwt-authorizer/tests/tonic.rs @@ -3,7 +3,7 @@ use std::{sync::Once, task::Poll}; use axum::body::HttpBody; use futures_core::future::BoxFuture; use http::header::AUTHORIZATION; -use jwt_authorizer::{layer::AsyncAuthorizationService, JwtAuthorizer}; +use jwt_authorizer::{layer::AsyncAuthorizationService, IntoLayer, JwtAuthorizer}; use serde::{Deserialize, Serialize}; use tonic::{server::UnaryService, transport::NamedService, IntoRequest, Status}; use tower::{buffer::Buffer, Service}; @@ -83,7 +83,7 @@ async fn app( jwt_auth: JwtAuthorizer, expected_sub: String, ) -> AsyncAuthorizationService>, User> { - let layer = jwt_auth.layer().await.unwrap(); + let layer = jwt_auth.into_layer().await.unwrap(); tonic::transport::Server::builder() .layer(layer) .layer(tower::buffer::BufferLayer::new(1))