packages feed

jwt 0.3.0 → 0.4.0

raw patch · 3 files changed

+18/−15 lines, 3 filesdep ~base

Dependency ranges changed: base

Files

changelog view
@@ -1,3 +1,8 @@+2014-08-02 0.4.0+================++	* Change the upper boundary of base from 4.7 to 4.8 (#5)+ 2014-06-02 0.3.0 ================ 
jwt.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                jwt-version:             0.3.0+version:             0.4.0 synopsis:            JSON Web Token (JWT) decoding and encoding license:             MIT license-file:        LICENSE@@ -31,7 +31,7 @@ library   exposed-modules:     Web.JWT   other-modules:       Web.Base64-  build-depends:       base >= 4.6 && < 4.7+  build-depends:       base >= 4.6 && < 4.8                      , cryptohash               >= 0.11                      , base64-bytestring        >= 1.0                      , bytestring               >= 0.10
tests/src/Web/JWTTests.hs view
@@ -88,9 +88,14 @@       , unregisteredClaims = Map.fromList [("http://example.com/is_root", Bool True)]     }         jwt = encodeUnsigned cs-    -- Verified using https://py-jwt-decoder.appspot.com/-    "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJodHRwOi8vZXhhbXBsZS5jb20vaXNfcm9vdCI6dHJ1ZSwiaXNzIjoiRm9vIn0." @=? jwt+    -- Verify the shape of the JWT, ensure the shape of the triple of+    -- <header>.<claims>.<signature>+    let (h:c:s:_) = T.splitOn "." jwt+    False @=? T.null h+    False @=? T.null c+    True  @=? T.null s + case_encodeDecodeJWTNoMac = do     let cs = def {         iss = stringOrURI "Foo"@@ -124,23 +129,16 @@         t   = encodeSigned HS256 key cs     iss' @=? tokenIssuer t --case_encodeJWTClaimsSet = do-    let cs = def {-        iss = stringOrURI "Foo"-    }-    -- This is a valid JWT string that can be decoded with the given secret using the ruby JWT library-    "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJGb28ifQ.dfhkuexBONtkewFjLNz9mZlFc82GvRkaZKD8Pd53zJ8" @=? encodeSigned HS256 (secret "secret") cs--case_encodeJWTClaimsSetCustomClaims = do+case_encodeDecodeJWTClaimsSetCustomClaims = do     let now = 1234         cs = def {         iss = stringOrURI "Foo"       , iat = intDate now       , unregisteredClaims = Map.fromList [("http://example.com/is_root", Bool True)]     }-    -- The expected string can be decoded using the ruby-jwt library-    "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjEyMzQsImh0dHA6Ly9leGFtcGxlLmNvbS9pc19yb290Ijp0cnVlLCJpc3MiOiJGb28ifQ.F3VCSxBBnY2caX4AH4GvIHyTVUhOnJF9Av_G_N4m710" @=? encodeSigned HS256 (secret "secret") cs+    let secret' = secret "secret"+        jwt = decodeAndVerifySignature secret' $ encodeSigned HS256 secret' cs+    Just cs @=? fmap claims jwt   prop_stringOrURIProp = f