frasertweedale / hs-jose

Haskell JOSE and JWT library
http://hackage.haskell.org/package/jose
Apache License 2.0
122 stars 46 forks source link

JWT: implement "nbf" and "exp" processing #15

Closed whittle closed 8 years ago

whittle commented 8 years ago

Mostly as discussed in #9 with the following exceptions:

  1. validateClaimsSet is exported from Crypto.JWT separately from validateJWSJWT, mostly for ease of testing. Doing so may lead some users to only validate the claims, without realizing that they need to validate the signature as well. I added an additional warning to try to prevent this.
  2. Prior to these commits, the signature of validateJWSJWT had been changed to use ValidationsSettings instead of ValidationAlgorithms and ValidationPolicy. I left it as it was, choosing to defer to the code over the discussion in #9.
  3. I did not provide validateJWSJWTWithTime, as was discussed in #9. The implementation uses MonadTime, of which IO and any mtl stack terminating in IO are all instances, and (as demonstrated in the tests) it is straightforward to make Reader UTCTime an instance for testing purposes. I believe that this covers any use cases that would be served by validateJWSJWTWithTime without tempting unsophisticated users to perform unsafe IO.