JWT-CPP v0.7.0
A header only library for creating and validating JSON Web Tokens (JWT) in C++
|
#include <jwt.h>
Public Member Functions | |
JWT_CLAIM_EXPLICIT | builder (Clock c) |
builder & | set_header_claim (const typename json_traits::string_type &id, typename json_traits::value_type c) |
builder & | set_header_claim (const typename json_traits::string_type &id, basic_claim< json_traits > c) |
builder & | set_payload_claim (const typename json_traits::string_type &id, typename json_traits::value_type c) |
builder & | set_payload_claim (const typename json_traits::string_type &id, basic_claim< json_traits > c) |
builder & | set_algorithm (typename json_traits::string_type str) |
Set algorithm claim You normally don't need to do this, as the algorithm is automatically set if you don't change it. | |
builder & | set_type (typename json_traits::string_type str) |
builder & | set_content_type (typename json_traits::string_type str) |
builder & | set_key_id (typename json_traits::string_type str) |
Set key id claim. | |
builder & | set_issuer (typename json_traits::string_type str) |
builder & | set_subject (typename json_traits::string_type str) |
builder & | set_audience (typename json_traits::array_type a) |
builder & | set_audience (typename json_traits::string_type aud) |
builder & | set_expires_at (const date &d) |
template<class Rep > | |
builder & | set_expires_in (const std::chrono::duration< Rep > &d) |
builder & | set_not_before (const date &d) |
builder & | set_issued_at (const date &d) |
builder & | set_issued_now () |
builder & | set_id (const typename json_traits::string_type &str) |
template<typename Algo , typename Encode > | |
json_traits::string_type | sign (const Algo &algo, Encode encode) const |
template<typename Algo > | |
json_traits::string_type | sign (const Algo &algo) const |
template<typename Algo , typename Encode > | |
json_traits::string_type | sign (const Algo &algo, Encode encode, std::error_code &ec) const |
template<typename Algo > | |
json_traits::string_type | sign (const Algo &algo, std::error_code &ec) const |
Builder class to build and sign a new token Use jwt::create() to get an instance of this class.
|
inline |
Constructor for building a new builder instance
c | Clock instance |
|
inline |
Set algorithm claim You normally don't need to do this, as the algorithm is automatically set if you don't change it.
str | Name of algorithm |
|
inline |
Set audience claim
a | Audience set |
|
inline |
Set audience claim
aud | Single audience |
|
inline |
Set content type claim
str | Type to set |
|
inline |
Set expires at claim
d | Expires time |
|
inline |
Set expires at claim to d
from the current moment
d | token expiration timeout |
|
inline |
Set a header claim.
id | Name of the claim |
c | Claim to add |
|
inline |
Set a header claim.
id | Name of the claim |
c | Claim to add |
|
inline |
Set id claim
str | ID to set |
|
inline |
Set issued at claim
d | Issued at time, should be current time |
|
inline |
Set issued at claim to the current moment
|
inline |
Set issuer claim
str | Issuer to set |
|
inline |
Set key id claim.
str | Key id to set |
|
inline |
Set not before claim
d | First valid time |
|
inline |
Set a payload claim.
id | Name of the claim |
c | Claim to add |
|
inline |
Set a payload claim.
id | Name of the claim |
c | Claim to add |
|
inline |
Set subject claim
str | Subject to set |
|
inline |
Set type claim
str | Type to set |
|
inline |
Sign token and return result
using the jwt::base
functions provided
algo | Instance of an algorithm to sign the token with |
|
inline |
Sign token and return result
Algo | Callable method which takes a string_type and return the signed input as a string_type |
Encode | Callable method which takes a string_type and base64url safe encodes it, MUST return the result with no padding; trim the result. |
algo | Instance of an algorithm to sign the token with |
encode | Callable to transform the serialized json to base64 with no padding |
algo.name()
|
inline |
Sign token and return result
Algo | Callable method which takes a string_type and return the signed input as a string_type |
Encode | Callable method which takes a string_type and base64url safe encodes it, MUST return the result with no padding; trim the result. |
algo | Instance of an algorithm to sign the token with |
encode | Callable to transform the serialized json to base64 with no padding |
ec | error_code filled with details on error |
algo.name()
|
inline |
Sign token and return result
using the jwt::base
functions provided
algo | Instance of an algorithm to sign the token with |
ec | error_code filled with details on error |