Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode without validation? #330

Closed
lcmgh opened this issue Oct 5, 2023 · 2 comments
Closed

Decode without validation? #330

lcmgh opened this issue Oct 5, 2023 · 2 comments

Comments

@lcmgh
Copy link

lcmgh commented Oct 5, 2023

Hi!

I want to extract the exp timestamp from the token without validating it in order to build a small lib that requests a new token before the current one expires. Hence I don't need to validate it but read the exp date.

Is that possible?

@Keats
Copy link
Owner

Keats commented Oct 5, 2023

@lcmgh
Copy link
Author

lcmgh commented Oct 5, 2023

Thanks @Keats.

let mut no_validation = Validation::default();
no_validation.insecure_disable_signature_validation();

let dummy_decoding_key = DecodingKey::from_rsa_components("", "").unwrap();

let decoded_token =
    decode::<HashMap<String, serde_json::Value>>(token, &dummy_decoding_key, &no_validation)
        .unwrap();
println!("{:?}", decoded_token);

@lcmgh lcmgh closed this as completed Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants