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

Safe HaskellNone
LanguageHaskell2010

Jose.Jwt

Synopsis

Documentation

data Jwt Source

A decoded JWT which can be either a JWE or a JWS.

Constructors

Jws !Jws 
Jwe !Jwe 

Instances

type Jwe = (JweHeader, ByteString) Source

The header and claims of a decoded JWE.

type Jws = (JwsHeader, ByteString) Source

The header and claims of a decoded JWS.

data JwtClaims Source

Registered claims defined in section 4 of the JWT spec.

Constructors

JwtClaims 

Fields

jwtIss :: !(Maybe Text)
 
jwtSub :: !(Maybe Text)
 
jwtAud :: !(Maybe [Text])
 
jwtExp :: !(Maybe IntDate)
 
jwtNbf :: !(Maybe IntDate)
 
jwtIat :: !(Maybe IntDate)
 
jwtJti :: !(Maybe Text)
 

data JwsHeader Source

Header content for a JWS.

Constructors

JwsHeader 

data JwtError Source

Decoding errors.

Constructors

KeyError Text

No suitable key or wrong key type

BadAlgorithm Text

The supplied algorithm is invalid

BadDots Int

Wrong number of "." characters in the JWT

BadHeader

Header couldn't be decoded or contains bad data

BadClaims

Claims part couldn't be decoded or contains bad data

BadSignature

Signature is invalid

BadCrypto

A cryptographic operation failed

Base64Error String

A base64 decoding error

Instances

decode Source

Arguments

:: CPRG g 
=> g 
-> [Jwk]

The keys to use for decoding

-> ByteString

The encoded JWT

-> (Either JwtError Jwt, g)

The decoded JWT, if successful

Uses the supplied keys to decode a JWT. Locates a matching key by header kid value where possible or by suitable key type. The JWK use and alg options are currently ignored.

decodeClaims :: ByteString -> Either JwtError (JwtHeader, JwtClaims) Source

Convenience function to return the claims contained in a JWT. This is required in situations such as client assertion authentication, where the contents of the JWT may be required in order to work out which key should be used to verify the token. Obviously this should not be used by itself to decode a token since no integrity checking is done and the contents may be forged.