pub fn dangerous_insecure_decode_with_validation<T: DeserializeOwned>(
    token: &str,
    validation: &Validation
) -> Result<TokenData<T>>
Expand description

Decode and validate a JWT without any signature verification.

If the token is invalid or the claims fail validation, it will return an error.

NOTE: Do not use this unless you know what you are doing! If the token’s signature is invalid, it will not return an error.

use serde::{Deserialize, Serialize};
use jsonwebtoken::{dangerous_insecure_decode_with_validation, Validation, Algorithm};

#[derive(Debug, Serialize, Deserialize)]
struct Claims {
   sub: String,
   company: String
}

let token = "a.jwt.token";
// Claims is a struct that implements Deserialize
let token_message = dangerous_insecure_decode_with_validation::<Claims>(&token, &Validation::new(Algorithm::HS256));