Keats / jsonwebtoken

JWT lib in rust
MIT License
1.64k stars 260 forks source link

Inconsistency in the docs regarding validation #294

Open ahmadardal opened 1 year ago

ahmadardal commented 1 year ago

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

Keats commented 1 year ago

Ah the docs should be updated.

ahmadardal commented 1 year ago

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;
Keats commented 1 year ago

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