jsonwebtoken icon indicating copy to clipboard operation
jsonwebtoken copied to clipboard

Inconsistency in the docs regarding validation

Open ahmadardal opened this issue 2 years ago • 3 comments

Hello!

According to the docs, if we want to extend the Validation rules we can do it like the example provided in the docs:

// Changing one parameter
let mut validation = Validation {leeway: 60, ..Default::default()};

However if we use this code, we get the following error:

58 |     let mut validation = Validation {leeway: 1000 * 60, ..Default::default()};
   |                                                           ^^^^^^^^^^^^^^^^^^ field `validate_signature` is private

This issue is addressed already before but it was weirdly closed without either fixing it or providing an alternative way to bypass the error and update the docs for it.

https://github.com/Keats/jsonwebtoken/issues/255

ahmadardal avatar Feb 24 '23 15:02 ahmadardal

Ah the docs should be updated.

Keats avatar Feb 24 '23 16:02 Keats

Yea that would be nice. In the meantime, would you say that my workaround is the recommended way now?

    let mut validation = Validation::default();
    validation.leeway = 60;

ahmadardal avatar Feb 24 '23 16:02 ahmadardal

That or Validation::new(Algorithm::..) with the alg you are using

Keats avatar Feb 24 '23 16:02 Keats