[][src]Function jsonwebtoken::dangerous_unsafe_decode

pub fn dangerous_unsafe_decode<T: DeserializeOwned>(
    token: &str
) -> Result<TokenData<T>>

Decode a JWT without any signature verification/validations.

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_unsafe_decode, Validation, Algorithm};

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

let token = "a.jwt.token".to_string();
// Claims is a struct that implements Deserialize
let token_message = dangerous_unsafe_decode::<Claims>(&token);