pub struct ClientJwtInterceptor<P: TokenProvider> { /* private fields */ }Expand description
Generic interceptor that calls any TokenProvider and attaches the result
as a Bearer token on every outbound gRPC request.
Used internally by the from_endpoint_with_provider constructor that
#[derive(GrpcClient)] generates on every client struct; consumers do not
typically construct this directly.
To forward the caller’s token from an incoming request to a downstream
service, use crate::auth::extract_token to obtain a rust_auth_lib::ForwardedToken
and pass it as the provider:
ⓘ
#[rust_grpc_lib::keycloak_authenticated_service]
impl Daq for MyDaqService {
async fn get_data(&self, req: Request<GetDataRequest>) -> Result<Response<GetDataResponse>, Status> {
let provider = rust_grpc_lib::auth::extract_token(&req)?;
let client = AlarmCommandsClient::from_endpoint_with_provider(
"http://alarm-host:50051",
provider,
)?;
// ...
}
}Implementations§
Source§impl<P: TokenProvider> ClientJwtInterceptor<P>
impl<P: TokenProvider> ClientJwtInterceptor<P>
Trait Implementations§
Source§impl<P: TokenProvider> Interceptor for ClientJwtInterceptor<P>
impl<P: TokenProvider> Interceptor for ClientJwtInterceptor<P>
Auto Trait Implementations§
impl<P> Freeze for ClientJwtInterceptor<P>where
P: Freeze,
impl<P> RefUnwindSafe for ClientJwtInterceptor<P>where
P: RefUnwindSafe,
impl<P> Send for ClientJwtInterceptor<P>
impl<P> Sync for ClientJwtInterceptor<P>
impl<P> Unpin for ClientJwtInterceptor<P>where
P: Unpin,
impl<P> UnsafeUnpin for ClientJwtInterceptor<P>where
P: UnsafeUnpin,
impl<P> UnwindSafe for ClientJwtInterceptor<P>where
P: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Applies the layer to a service and wraps it in [
Layered].