GrpcAuthExt

Trait GrpcAuthExt 

Source
pub trait GrpcAuthExt<T> {
    // Required method
    fn auth_context<C: Clone + Send + Sync + 'static>(
        &self,
    ) -> Option<&AuthContext<C>>;

    // Provided methods
    fn claims<C: Clone + Send + Sync + 'static>(&self) -> Option<&C> { ... }
    fn require_auth<C: Clone + Send + Sync + 'static>(
        &self,
    ) -> Result<&C, Status> { ... }
}
Available on crate features auth and auth-tonic only.
Expand description

Extension trait for extracting auth context from gRPC requests.

Required Methods§

Source

fn auth_context<C: Clone + Send + Sync + 'static>( &self, ) -> Option<&AuthContext<C>>

Get the auth context if present.

Provided Methods§

Source

fn claims<C: Clone + Send + Sync + 'static>(&self) -> Option<&C>

Get the claims if authenticated.

Source

fn require_auth<C: Clone + Send + Sync + 'static>(&self) -> Result<&C, Status>

Get the claims, returning an error if not authenticated.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> GrpcAuthExt<T> for Request<T>

Source§

fn auth_context<C: Clone + Send + Sync + 'static>( &self, ) -> Option<&AuthContext<C>>

Available on crate feature auth-tonic only.

Implementors§