Main class to work with JWT.
More...
#include <jwt.h>
Main class to work with JWT.
◆ JWT() [1/2]
Constructs a JWT from a token.
- Parameters
-
| token | the token; |
| key | key to use for signatire verification; |
| validators | an optional list of validators; validates 'exp' by default. |
◆ JWT() [2/2]
Constructs a JWT from scratch.
- Parameters
-
| alg | signature algorithm; |
| claims | a list of claims; |
| header | an optional list of header records; 'alg' and 'typ' can't be specified manually. |
◆ claim()
| Value JWTXX::JWT::claim |
( |
const std::string & | name | ) |
const |
|
noexcept |
Returns a value of a specific claim.
- Parameters
-
- Note
- Returns an empty string if the claim is missing.
◆ parse()
| static JWT JWTXX::JWT::parse |
( |
const std::string & | token | ) |
|
|
static |
Returns a JWT for a token without validation.
- Parameters
-
◆ token() [1/2]
| std::string JWTXX::JWT::token |
( |
const Key & | key | ) |
const |
Returns a signed token using a pre-constructed key.
- Parameters
-
| key | cryptographic key to use for signing. |
- Returns
- signed JWT token string.
- Note
- This overload allows key reuse for better performance when generating multiple tokens.
-
The key algorithm must match the algorithm specified in this JWT.
◆ token() [2/2]
Returns a signed token.
- Parameters
-
| keyData | key-specific data; |
| cb | password callback for password-protected keys. |
- Note
- Automatically constructs key using the algorithm specified in this JWT.
◆ verify()
Validates a token without constructing a JWT.
- Parameters
-
| token | the token; |
| key | key to use for signatire verification; |
| validators | an optional list of validators; validates 'exp' by default. |
The documentation for this class was generated from the following file: