| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Jose.Jws
Description
JWS HMAC and RSA signed token support.
Example usage with HMAC:
>>>import Jose.Jws>>>import Jose.Jwa>>>let jwt = hmacEncode HS256 "secretmackey" "secret claims">>>jwt"eyJhbGciOiJIUzI1NiJ9.c2VjcmV0IGNsYWltcw.Hk9VZbfMHEC_IGVHnAi25HgWR91XMneqYCl7F5izQkM">>>hmacDecode "wrongkey" jwtLeft BadSignature>>>hmacDecode "secretmackey" jwtRight (JwsHeader {jwsAlg = HS256, jwsTyp = Nothing, jwsCty = Nothing, jwsKid = Nothing},"secret claims")
- hmacEncode :: JwsAlg -> ByteString -> ByteString -> ByteString
- hmacDecode :: ByteString -> ByteString -> Either JwtError Jws
- rsaEncode :: JwsAlg -> PrivateKey -> ByteString -> ByteString
- rsaDecode :: PublicKey -> ByteString -> Either JwtError Jws
Documentation
Arguments
| :: JwsAlg | The MAC algorithm to use |
| -> ByteString | The MAC key |
| -> ByteString | The JWT claims (token content) |
| -> ByteString | The encoded JWS token |
Create a JWS with an HMAC for validation.
Arguments
| :: ByteString | The HMAC key |
| -> ByteString | The JWS token to decode |
| -> Either JwtError Jws | The decoded token if successful |
Decodes and validates an HMAC signed JWS.
Arguments
| :: JwsAlg | The RSA algorithm to use |
| -> PrivateKey | The key to sign with |
| -> ByteString | The JWT claims (token content) |
| -> ByteString | The encoded JWS token |
Creates a JWS with an RSA signature.