pub trait JWTSession: Clone + SessionCreator {
    // Required methods
    fn initial_validation(&self, jwt: &JWT) -> Result<(), Error>;
    fn build_from_req(
        &self,
        req: &Request
    ) -> Result<HashMap<String, String>, Error>;

    // Provided method
    fn obtain_token_from_req(req: &Request) -> Result<JWT, Error> { ... }
}
Expand description

Ussage

Trait employed for HS256 and RS256 session to avoid code repetition and specify what needs to be done to verify JWT correctly The obtain_token_from_req function is the same in both cases, since it returns a JWT instance This trait is made public in case someone finds it useful.

Required Methods§

source

fn initial_validation(&self, jwt: &JWT) -> Result<(), Error>

Should perform any kind of validation necessary before reading and manipulating the request

source

fn build_from_req( &self, req: &Request ) -> Result<HashMap<String, String>, Error>

Build session from incoming request. Should return a HashMap with values needed to validate session and possibly receive user information (through jwt)

Provided Methods§

source

fn obtain_token_from_req(req: &Request) -> Result<JWT, Error>

From request extract JWT to manipulate it easier later on

Implementors§