qb
2.0.0.0
C++17 Actor Framework
|
Comprehensive JWT implementation for the QB IO library. More...
#include <crypto_jwt.h>
Classes | |
struct | CreateOptions |
JWT creation options. More... | |
struct | TokenParts |
JWT token parts. More... | |
struct | ValidationResult |
Result of JWT validation containing error code and payload if valid. More... | |
struct | VerifyOptions |
JWT verification options. More... |
Public Types | |
enum class | Algorithm { HS256 , HS384 , HS512 , RS256 , RS384 , RS512 , ES256 , ES384 , ES512 , EdDSA } |
Supported JWT signing algorithms. More... | |
enum class | ValidationError { NONE , INVALID_FORMAT , INVALID_SIGNATURE , TOKEN_EXPIRED , TOKEN_NOT_ACTIVE , INVALID_ISSUER , INVALID_AUDIENCE , INVALID_SUBJECT , CLAIM_MISMATCH } |
JWT validation error codes. |
Static Public Member Functions | |
static std::string | create (const std::map< std::string, std::string > &payload, const CreateOptions &options) |
Create a JWT token with custom payload and options. | |
static std::string | create_token (const std::map< std::string, std::string > &payload, const std::string &issuer, const std::string &subject, const std::string &audience, std::chrono::seconds expires_in, std::chrono::seconds not_before=std::chrono::seconds(0), const std::string &jti="", const CreateOptions &options=CreateOptions()) |
Create a JWT token with standard claims and custom payload. | |
static ValidationResult | verify (const std::string &token, const VerifyOptions &options) |
Verify a JWT token. | |
static TokenParts | decode (const std::string &token) |
Decode a JWT token without verification. | |
static std::string | algorithm_to_string (Algorithm algorithm) |
Get string representation of algorithm. | |
static std::optional< Algorithm > | algorithm_from_string (const std::string &algorithm_str) |
Get algorithm from string representation. |
Comprehensive JWT implementation for the QB IO library.
This class provides functionality for creating, signing, and verifying JSON Web Tokens (JWT) according to RFC 7519. It supports multiple signing algorithms and standard JWT claims validation.
|
strong |
Supported JWT signing algorithms.
Enumerator | |
---|---|
HS256 | HMAC using SHA-256. |
HS384 | HMAC using SHA-384. |
HS512 | HMAC using SHA-512. |
RS256 | RSASSA-PKCS1-v1_5 using SHA-256. |
RS384 | RSASSA-PKCS1-v1_5 using SHA-384. |
RS512 | RSASSA-PKCS1-v1_5 using SHA-512. |
ES256 | ECDSA using P-256 and SHA-256. |
ES384 | ECDSA using P-384 and SHA-384. |
ES512 | ECDSA using P-521 and SHA-512. |
EdDSA | Edwards-curve Digital Signature Algorithm (Ed25519) |
|
static |
Create a JWT token with custom payload and options.
payload | Map of claims to include in the payload |
options | Options for creating the token |
|
static |
Create a JWT token with standard claims and custom payload.
payload | Map of custom claims to include in the payload |
issuer | Token issuer |
subject | Token subject |
audience | Token audience |
expires_in | Token expiration time in seconds from now |
not_before | Token not valid before time in seconds from now (default: 0) |
jti | Unique JWT ID |
options | Options for creating the token |
|
static |
Verify a JWT token.
token | JWT token to verify |
options | Options for verifying the token |
|
static |
Decode a JWT token without verification.
token | JWT token to decode |
std::runtime_error | if token format is invalid |
|
static |
Get string representation of algorithm.
algorithm | Algorithm to convert to string |