pub trait AuthHandler<Data> {
    fn jwt_secret<F: FnOnce() -> Option<Data>>(
        &self,
        state: &mut State,
        decode_data: F
    ) -> Option<Vec<u8>>; }
Expand description

This trait will help the auth middleware to determine the validity of an authentication token.

A very basic implementation could look like this:

const SECRET : &'static [u8; 32] = b"zlBsA2QXnkmpe0QTh8uCvtAEa4j33YAc";

struct CustomAuthHandler;
impl<T> AuthHandler<T> for CustomAuthHandler {
	fn jwt_secret<F : FnOnce() -> Option<T>>(&self, _state : &mut State, _decode_data : F) -> Option<Vec<u8>> {
		Some(SECRET.to_vec())
	}
}

Required methods

Return the SHA256-HMAC secret used to verify the JWT token.

Implementors