Goby3  3.1.5a
2024.05.23
jwt Namespace Reference

JSON Web Token. More...

Namespaces

 algorithm
 Various cryptographic algorithms when working with JWT.
 
 alphabet
 character maps when encoding and decoding
 
 details
 
 error
 Everything related to error codes issued by the library.
 
 helper
 A collection for working with certificates.
 
 json
 JSON Abstractions for working with any library.
 
 traits
 
 verify_ops
 

Classes

class  base
 Alphabet generic methods for working with encoding/decoding the base64 family. More...
 
class  basic_claim
 a class to store a generic JSON value as claim More...
 
class  builder
 
class  decoded_jwt
 
struct  default_clock
 
class  header
 
class  jwk
 JSON Web Key. More...
 
class  jwks
 JWK Set. More...
 
class  payload
 
class  verifier
 

Typedefs

using date = std::chrono::system_clock::time_point
 
using claim = basic_claim< traits::nlohmann_json >
 a class to store a generic JSON for Modern C++ value as claim More...
 

Functions

template<typename Clock , typename json_traits >
verifier< Clock, json_traits > verify (Clock c)
 
template<typename json_traits >
verifier< default_clock, json_traits > verify (default_clock c={})
 
template<typename json_traits >
builder< json_traits > create ()
 
template<typename json_traits , typename Decode >
decoded_jwt< json_traits > decode (const typename json_traits::string_type &token, Decode decode)
 
template<typename json_traits >
decoded_jwt< json_traits > decode (const typename json_traits::string_type &token)
 
template<typename json_traits >
jwk< json_traits > parse_jwk (const typename json_traits::string_type &token)
 
template<typename json_traits >
jwks< json_traits > parse_jwks (const typename json_traits::string_type &token)
 
verifier< default_clock, traits::nlohmann_jsonverify ()
 
decoded_jwt< traits::nlohmann_jsondecode (const std::string &token)
 
template<typename Decode >
decoded_jwt< traits::nlohmann_jsondecode (const std::string &token, Decode decode)
 
jwk< traits::nlohmann_jsonparse_jwk (const traits::nlohmann_json::string_type &token)
 
jwks< traits::nlohmann_jsonparse_jwks (const traits::nlohmann_json::string_type &token)
 

Detailed Description

JSON Web Token.

A namespace to contain everything related to handling JSON Web Tokens, JWT for short, as a part of RFC7519, or alternatively for JWS (JSON Web Signature) from RFC7515

Typedef Documentation

◆ claim

a class to store a generic JSON for Modern C++ value as claim

This type is the specialization of the basic_claim class which uses the standard template types.

Definition at line 18 of file defaults.h.

◆ date

using jwt::date = typedef std::chrono::system_clock::time_point

Default system time point in UTC

Definition at line 79 of file jwt.h.

Function Documentation

◆ create()

template<typename json_traits >
builder< traits::nlohmann_json > jwt::create ( )
inline

Return a builder instance to create a new token

Definition at line 4168 of file jwt.h.

◆ decode() [1/4]

decoded_jwt<traits::nlohmann_json> jwt::decode ( const std::string &  token)
inline

Decode a token

Parameters
tokenToken to decode
Returns
Decoded token
Exceptions
std::invalid_argumentToken is not in correct format
std::runtime_errorBase64 decoding failed or invalid json

Definition at line 42 of file defaults.h.

◆ decode() [2/4]

template<typename Decode >
decoded_jwt<traits::nlohmann_json> jwt::decode ( const std::string &  token,
Decode  decode 
)

Decode a token

Template Parameters
Decodeis callabled, taking a string_type and returns a string_type. It should ensure the padding of the input and then base64url decode and return the results.
Parameters
tokenToken to decode
decodeThe token to parse
Returns
Decoded token
Exceptions
std::invalid_argumentToken is not in correct format
std::runtime_errorBase64 decoding failed or invalid json

Definition at line 60 of file defaults.h.

◆ decode() [3/4]

template<typename json_traits >
decoded_jwt<json_traits> jwt::decode ( const typename json_traits::string_type &  token)

Decode a token

Parameters
tokenToken to decode
Returns
Decoded token
Exceptions
std::invalid_argumentToken is not in correct format
std::runtime_errorBase64 decoding failed or invalid json

Definition at line 4192 of file jwt.h.

◆ decode() [4/4]

template<typename json_traits , typename Decode >
decoded_jwt<json_traits> jwt::decode ( const typename json_traits::string_type &  token,
Decode  decode 
)

Decode a token

Parameters
tokenToken to decode
decodefunction that will pad and base64url decode the token
Returns
Decoded token
Exceptions
std::invalid_argumentToken is not in correct format
std::runtime_errorBase64 decoding failed or invalid json

Definition at line 4179 of file jwt.h.

◆ parse_jwk() [1/2]

jwk<traits::nlohmann_json> jwt::parse_jwk ( const traits::nlohmann_json::string_type token)
inline

Parse a jwk

Parameters
tokenJWK Token to parse
Returns
Parsed JWK
Exceptions
std::runtime_errorToken is not in correct format

Definition at line 71 of file defaults.h.

◆ parse_jwk() [2/2]

template<typename json_traits >
jwk<json_traits> jwt::parse_jwk ( const typename json_traits::string_type &  token)

Definition at line 4198 of file jwt.h.

◆ parse_jwks() [1/2]

jwks<traits::nlohmann_json> jwt::parse_jwks ( const traits::nlohmann_json::string_type token)
inline

Parse a jwks

Parameters
tokenJWKs Token to parse
Returns
Parsed JWKs
Exceptions
std::runtime_errorToken is not in correct format

Definition at line 82 of file defaults.h.

◆ parse_jwks() [2/2]

template<typename json_traits >
jwks<json_traits> jwt::parse_jwks ( const typename json_traits::string_type &  token)

Definition at line 4204 of file jwt.h.

◆ verify() [1/3]

verifier<default_clock, traits::nlohmann_json> jwt::verify ( )
inline

Create a verifier using the default clock

Returns
verifier instance

Definition at line 24 of file defaults.h.

◆ verify() [2/3]

template<typename Clock , typename json_traits >
verifier<Clock, json_traits> jwt::verify ( Clock  c)

Create a verifier using the given clock

Parameters
cClock instance to use
Returns
verifier instance

Definition at line 4142 of file jwt.h.

◆ verify() [3/3]

template<typename json_traits >
verifier<default_clock, json_traits> jwt::verify ( default_clock  c = {})

Create a verifier using the given clock

Parameters
cClock instance to use
Returns
verifier instance

Definition at line 4160 of file jwt.h.