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

Nonce validation #352

Open
aagmv opened this issue Dec 14, 2023 · 1 comment
Open

Nonce validation #352

aagmv opened this issue Dec 14, 2023 · 1 comment

Comments

@aagmv
Copy link

aagmv commented Dec 14, 2023

OIDC has a nonce mechanism that gets included in the JWT to prevent replay attacks.
Comparing it after decoding isn't particularly difficult, but neither would be checking the issuer or audience.

It still might be useful to integrate it as part of the decode-and-validate step. This could maybe done be similarly to the set_required_spec_claims method, with a set_expected_claim_values.

The downside is that it forces a new Validation object to be allocated on every request because the nonce changes every time.

fn process_token(raw_token: &str, nonce: &str) -> Result<Decoded> {
   let mut val = Validation::default();
   /// ...
   val.set_expected_claim_values(HashMap::from([("nonce", nonce)]))

   decode::<Claims>(raw_token, todo!(), &val)
}
@Keats
Copy link
Owner

Keats commented Dec 17, 2023

Hmm I don't think this would belong to the library because of the need to instantiate a new Validation object as you say.

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