Skip to main content

TokenVerifier

Trait TokenVerifier 

Source
pub trait TokenVerifier:
    Send
    + Sync
    + 'static {
    // Required method
    fn verify<'a>(
        &'a self,
        token: &'a str,
    ) -> Pin<Box<dyn Future<Output = Result<Principal, TokenError>> + Send + 'a>>;
}
Expand description

Checks an access token and identifies its holder.

Implementations must check that the token was issued for this server (audience), is unexpired, and is authentic; the specification forbids accepting tokens meant for other resources. The oauth feature provides JwtVerifier for JWT access tokens; implement this trait for other formats (for example token introspection).

Required Methods§

Source

fn verify<'a>( &'a self, token: &'a str, ) -> Pin<Box<dyn Future<Output = Result<Principal, TokenError>> + Send + 'a>>

Verifies token (the value after Bearer ).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl TokenVerifier for JwtVerifier

Source§

impl<F> TokenVerifier for F
where F: Fn(&str) -> Result<Principal, TokenError> + Send + Sync + 'static,