[][src]Trait roa::jwt::JwtVerifier

pub trait JwtVerifier<S> {
    fn claims<C>(&self) -> Result<C>
    where
        C: 'static + DeserializeOwned
;
fn verify<C>(&self, validation: &Validation) -> Result<C>
    where
        C: 'static + DeserializeOwned
; }

A context extension. This extension must be used in downstream of middleware guard or guard_by, otherwise you cannot get expected claims.

Example

use roa::{Context, Result};
use roa::jwt::JwtVerifier;
use serde_json::Value;

async fn get(ctx: Context<()>) -> Result {
    let claims: Value = ctx.claims()?;
    Ok(())
}

Required methods

fn claims<C>(&self) -> Result<C> where
    C: 'static + DeserializeOwned

Deserialize claims from token.

fn verify<C>(&self, validation: &Validation) -> Result<C> where
    C: 'static + DeserializeOwned

Verify token and deserialize claims with a validation. Use this method if this validation is different from that one of guard or guard_by.

Loading content...

Implementors

impl<S> JwtVerifier<S> for SyncContext<S> where
    S: State
[src]

Loading content...