jose-jwt-0.1: JSON Object Signing and Encryption Library

Safe HaskellNone
LanguageHaskell2010

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" jwt
Left BadSignature
>>> hmacDecode "secretmackey" jwt
Right (JwsHeader {jwsAlg = HS256, jwsTyp = Nothing, jwsCty = Nothing, jwsKid = Nothing},"secret claims")

Synopsis

Documentation

hmacEncode Source

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.

hmacDecode Source

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.

rsaEncode Source

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.

rsaDecode Source

Arguments

:: PublicKey

The key to check the signature with

-> ByteString

The encoded JWS

-> Either JwtError Jws

The decoded token if successful

Decode and validate an RSA signed JWS.