Keats / jsonwebtoken

JWT lib in rust
MIT License
1.69k stars 271 forks source link

Add dangerous_insecure_decode_with_validation #138

Closed giarc3 closed 4 years ago

giarc3 commented 4 years ago

Discussed in #135. Adds a new function dangerous_insecure_decode_with_validation, which is a middle-ground between decode and dangerous_unsafe_decode. It takes a Validation and uses the validate function to run validations, but it does not do any signature verification.

I added the same set of tests that decode and dangerous_unsafe_decode have:

  1. Regular
  2. Invalid token
  3. Invalid signature
  4. Invalid algorithm

The new function passes numbers 1 and 3, but fails for numbers 2 and 4.

Note: the tests appear to be failing due to compiling the latest version of base64 (v0.12.2) on Rust 1.39.0.