Apache Mesos
Classes | Public Types | Static Public Member Functions | Public Attributes | List of all members
process::http::authentication::JWT Class Reference

A JSON Web Token (JWT) implementation. More...

#include <jwt.hpp>

Classes

struct  Header
 

Public Types

enum  Alg { Alg::None, Alg::HS256, Alg::RS256 }
 

Static Public Member Functions

static Try< JWT, JWTErrorparse (const std::string &token)
 Parse an unsecured JWT. More...
 
static Try< JWT, JWTErrorparse (const std::string &token, const std::string &secret)
 Parse a JWT and validate its HS256 signature. More...
 
static Try< JWT, JWTErrorparse (const std::string &token, std::shared_ptr< RSA > publicKey)
 Parse a JWT and validate its RS256 signature. More...
 
static Try< JWT, JWTErrorcreate (const JSON::Object &payload)
 Create an unsecured JWT. More...
 
static Try< JWT, JWTErrorcreate (const JSON::Object &payload, const std::string &secret)
 Create a JWT with a HS256 signature. More...
 
static Try< JWT, JWTErrorcreate (const JSON::Object &payload, std::shared_ptr< RSA > privateKey)
 Create a JWT with a RS256 signature. More...
 

Public Attributes

const Header header
 
const JSON::Object payload
 
const Option< std::string > signature
 

Detailed Description

A JSON Web Token (JWT) implementation.

See also
RFC 7519

This implementation supports the 'none', 'RS256' and 'HS256' algorithms. Header parameters other than 'alg' and 'typ' aren't parsed. To comply with RFC 7515, headers with 'crit' parameter are invalid. Currently, only the 'exp' standard claim is validated. Applications that need to validate other claims need to do this in their validation logic.

Member Enumeration Documentation

Enumerator
None 
HS256 
RS256 

Member Function Documentation

static Try<JWT, JWTError> process::http::authentication::JWT::create ( const JSON::Object payload)
static

Create an unsecured JWT.

Parameters
payloadThe payload of the JWT.
Returns
The unsecured JWT representation if successful otherwise an Error.
static Try<JWT, JWTError> process::http::authentication::JWT::create ( const JSON::Object payload,
const std::string &  secret 
)
static

Create a JWT with a HS256 signature.

When creating a payload keep in mind that of the standard claims currently only 'exp' is validated during parsing.

Parameters
payloadThe payload of the JWT.
secretThe secret to sign the JWT with.
Returns
The signed JWT representation if successful otherwise an Error.
static Try<JWT, JWTError> process::http::authentication::JWT::create ( const JSON::Object payload,
std::shared_ptr< RSA >  privateKey 
)
static

Create a JWT with a RS256 signature.

When creating a payload keep in mind that of the standard claims currently only 'exp' is validated during parsing.

Parameters
payloadThe payload of the JWT.
privateKeyThe private key to sign the JWT with.
Returns
The signed JWT representation if successful otherwise an Error.
static Try<JWT, JWTError> process::http::authentication::JWT::parse ( const std::string &  token)
static

Parse an unsecured JWT.

Parameters
tokenThe JWT to parse.
Returns
The JWT representation if successful otherwise an Error.
static Try<JWT, JWTError> process::http::authentication::JWT::parse ( const std::string &  token,
const std::string &  secret 
)
static

Parse a JWT and validate its HS256 signature.

Parameters
tokenThe JWT to parse.
secretThe secret to validate the signature with.
Returns
The validated JWT representation if successful otherwise an Error.
static Try<JWT, JWTError> process::http::authentication::JWT::parse ( const std::string &  token,
std::shared_ptr< RSA >  publicKey 
)
static

Parse a JWT and validate its RS256 signature.

Parameters
tokenThe JWT to parse.
publicKeyThe public key to validate the signature with.
Returns
The validated JWT representation if successful otherwise an Error.

Member Data Documentation

const Header process::http::authentication::JWT::header
const JSON::Object process::http::authentication::JWT::payload
const Option<std::string> process::http::authentication::JWT::signature

The documentation for this class was generated from the following file: