|
LibJWT 3.4.0
The C JSON Web Token Library +JWK +JWKS
|
Get and set claims and headers on a jwt_t during a callback. More...
Data Structures | |
| struct | jwt_config_t |
| Structure used to pass state with a user callback. More... | |
Typedefs | |
| typedef struct jwt | jwt_t |
| Opaque JWT object. | |
| typedef int(* | jwt_callback_t) (jwt_t *, jwt_config_t *) |
| General callback for generation and verification of JWT. | |
| typedef char *(* | jwt_jti_gen_cb_t) (const jwt_t *, jwt_config_t *) |
| Callback to generate a jti (JWT ID) when building a token. | |
| typedef int(* | jwt_jti_check_cb_t) (const jwt_t *, jwt_config_t *, const char *) |
| Callback to verify a jti (JWT ID) when checking a token. | |
Functions | |
| jwt_value_error_t | jwt_header_set (jwt_t *jwt, jwt_value_t *value) |
| Set a value in the header of a JWT. | |
| jwt_value_error_t | jwt_header_get (jwt_t *jwt, jwt_value_t *value) |
| Get a value from the header of a JWT. | |
| jwt_value_error_t | jwt_header_del (jwt_t *jwt, const char *header) |
| Delete a value from the header of a JWT. | |
| jwt_value_error_t | jwt_claim_set (jwt_t *jwt, jwt_value_t *value) |
| Set a value in the claims of a JWT. | |
| jwt_value_error_t | jwt_claim_get (jwt_t *jwt, jwt_value_t *value) |
| Get a value from the claims of a JWT. | |
| jwt_value_error_t | jwt_claim_del (jwt_t *jwt, const char *claim) |
| Delete a value from the claims of a JWT. | |
Get and set claims and headers on a jwt_t during a callback.
For most usage, setting values in the builder object is enough to provide all the information you would like set in a JWT token. However, if some information is dynamic, meaning it is only known at the time the token is created, then you can provide this during the builder callback on the jwt_t object.
When verifying a token, the checker callback should not modify the jwt_t object at all. Access to the jwt_t is provided only to allow additional validation beyond LibJWT's internal checks.
| typedef int(* jwt_callback_t) (jwt_t *, jwt_config_t *) |
General callback for generation and verification of JWT.
| typedef int(* jwt_jti_check_cb_t) (const jwt_t *, jwt_config_t *, const char *) |
Callback to verify a jti (JWT ID) when checking a token.
📄 RFC-7519 Sec 4.1.7 Receives the "jti" claim from the token. Return 0 to accept the token or non-zero to reject it (e.g. an unknown or already-consumed id). This is where an application implements replay protection against its own id pool.
| typedef char *(* jwt_jti_gen_cb_t) (const jwt_t *, jwt_config_t *) |
Callback to generate a jti (JWT ID) when building a token.
📄 RFC-7519 Sec 4.1.7 The returned string is set as the "jti" claim and then freed by LibJWT, so it must be allocated with whatever allocator LibJWT is currently using: plain malloc() if jwt_set_alloc() was never called, otherwise the allocator passed to jwt_set_alloc(). Returning NULL aborts token generation. The application is responsible for ensuring the id is unique.
| typedef struct jwt jwt_t |
Opaque JWT object.
Used in callbacks when generating or verifying a JWT
| jwt_value_error_t jwt_claim_del | ( | jwt_t * | jwt, |
| const char * | claim ) |
Delete a value from the claims of a JWT.
| jwt | Pointer to a jwt_t token, previously created with jwt_create() |
| claim | The name of the claim to delete, or NULL to clear all claims |
| jwt_value_error_t jwt_claim_get | ( | jwt_t * | jwt, |
| jwt_value_t * | value ) |
Get a value from the claims of a JWT.
| jwt | Pointer to a jwt_t token, previously created with jwt_create() |
| value | A jwt_value_t structure with relevant actions filled in |
| jwt_value_error_t jwt_claim_set | ( | jwt_t * | jwt, |
| jwt_value_t * | value ) |
Set a value in the claims of a JWT.
| jwt | Pointer to a jwt_t token, previously created with jwt_create() |
| value | A jwt_value_t structure with relevant actions filled in |
| jwt_value_error_t jwt_header_del | ( | jwt_t * | jwt, |
| const char * | header ) |
Delete a value from the header of a JWT.
| jwt | Pointer to a jwt_t token, previously created with jwt_create() |
| header | The name of the header to delete, or NULL to clear the entire header |
| jwt_value_error_t jwt_header_get | ( | jwt_t * | jwt, |
| jwt_value_t * | value ) |
Get a value from the header of a JWT.
| jwt | Pointer to a jwt_t token, previously created with jwt_create() |
| value | A jwt_value_t structure with relevant actions filled in |
| jwt_value_error_t jwt_header_set | ( | jwt_t * | jwt, |
| jwt_value_t * | value ) |
Set a value in the header of a JWT.
| jwt | Pointer to a jwt_t token, previously created with jwt_create() |
| value | A jwt_value_t structure with relevant actions filled in |