JWT-CPP v0.7.0
A header only library for creating and validating JSON Web Tokens (JWT) in C++
|
#include <jwt.h>
Public Types | |
using | basic_claim_t = basic_claim<json_traits> |
using | verify_check_fn_t |
Verification function data structure. | |
Public Member Functions | |
verifier (Clock c) | |
verifier & | leeway (size_t leeway) |
verifier & | expires_at_leeway (size_t leeway) |
verifier & | not_before_leeway (size_t leeway) |
verifier & | issued_at_leeway (size_t leeway) |
verifier & | with_type (const typename json_traits::string_type &type, std::locale locale=std::locale{}) |
verifier & | with_issuer (const typename json_traits::string_type &iss) |
verifier & | with_subject (const typename json_traits::string_type &sub) |
verifier & | with_audience (const typename basic_claim_t::set_t &aud) |
verifier & | with_audience (const typename json_traits::string_type &aud) |
verifier & | with_id (const typename json_traits::string_type &id) |
verifier & | with_claim (const typename json_traits::string_type &name, verify_check_fn_t fn) |
verifier & | with_claim (const typename json_traits::string_type &name, basic_claim_t c) |
template<typename Algorithm > | |
verifier & | allow_algorithm (Algorithm alg) |
Add an algorithm available for checking. | |
void | verify (const decoded_jwt< json_traits > &jwt) const |
void | verify (const decoded_jwt< json_traits > &jwt, std::error_code &ec) const |
Verifier class used to check if a decoded token contains all claims required by your application and has a valid signature.
using jwt::verifier< Clock, json_traits >::verify_check_fn_t |
Verification function data structure.
This gets passed the current verifier, a reference to the decoded jwt, a reference to the key of this claim, as well as a reference to an error_code. The function checks if the actual value matches certain rules (e.g. equality to value x) and sets the error_code if it does not. Once a non zero error_code is encountered the verification stops and this error_code becomes the result returned from verify
|
inlineexplicit |
Constructor for building a new verifier instance
c | Clock instance |
|
inline |
Add an algorithm available for checking.
This is used to handle incomming tokens for predefined algorithms which the authorization server is provided. For example a small system where only a single RSA key-pair is used to sign tokens
Algorithm | any algorithm such as those provided by jwt::algorithm |
alg | Algorithm to allow |
|
inline |
Set leeway for expires at. If not specified the default leeway will be used.
leeway | Set leeway to use for expires at. |
|
inline |
Set leeway for issued at. If not specified the default leeway will be used.
leeway | Set leeway to use for issued at. |
|
inline |
Set default leeway to use.
leeway | Default leeway to use if not specified otherwise |
|
inline |
Set leeway for not before. If not specified the default leeway will be used.
leeway | Set leeway to use for not before. |
|
inline |
Verify the given token.
jwt | Token to check |
token_verification_exception | Verification failed |
|
inline |
Verify the given token.
jwt | Token to check |
ec | error_code filled with details on error |
|
inline |
Set an audience to check for. If any of the specified audiences is not present in the token the check fails.
aud | Audience to check for. |
|
inline |
Set an audience to check for. If the specified audiences is not present in the token the check fails.
aud | Audience to check for. |
|
inline |
Specify a claim to check for equality (both type & value). See the private-claims.cpp example.
name | Name of the claim to check for |
c | Claim to check for |
|
inline |
Specify a claim to check for using the specified operation. This is helpful for implementating application specific authentication checks such as the one seen in partial-claim-verifier.cpp
name | Name of the claim to check for |
fn | Function to use for verifying the claim |
|
inline |
Set an id to check for. Check is case sensitive.
id | ID to check for. |
|
inline |
Set an issuer to check for. Check is case sensitive.
iss | Issuer to check for. |
|
inline |
Set a subject to check for. Check is case sensitive.
sub | Subject to check for. |
|
inline |
Set an type to check for.
According to RFC 7519 Section 5.1, This parameter is ignored by JWT implementations; any processing of this parameter is performed by the JWT application. Check is case sensitive.
type | Type Header Parameter to check for. |
locale | Localization functionality to use when comparing |