frasertweedale / hs-jose

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

add complete JWT verification example #52

Closed frasertweedale closed 6 years ago

frasertweedale commented 7 years ago
10:22 <frphank_> frase: other libraries' "verifyJWT" function takes 2 strings, the JWT and the secret.
10:22 <frphank_> where is this function
10:22 <frphank_> I had to write it
10:39 <frase> wtf, strings.  no wai man
10:40 <frphank_> well I ended up finding the fromOctets and decodeCompact functions eventually so it's not like it 
                 isn't supported
10:40 <frphank_> you just have to puzzle it together yourself
frasertweedale commented 7 years ago
  let jwk = fromOctets . fromString $ "Ge6m8I`5W#f)Z+H]emaPz*/@*@UZ7R;R0/uBRpEVQS]^c5Mf{N@>oIc]~+F+S-m0"
      result = do
        jws <- decodeCompact . L.fromStrict . fromString $ "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1MDA2Mjk0NzMsImlzcyI6Inh5eiIsImV4cCI6MTUwMDcxNTg3Mywic3ViIjoyfQ.wTEERJbyRjzBtJY4piJwRE9SL4nJ4Hy87qbel4EEqm8"
        verifyJWS' (jwk :: JWK) (jws :: CompactJWS JWSHeader)
  result <- runExceptT $ result