table of contents
| jwt_checker_grp(3) | Library Functions Manual | jwt_checker_grp(3) |
NAME¶
jwt_checker_grp - Checker
SYNOPSIS¶
Typedefs¶
typedef struct jwt_checker jwt_checker_t
Opaque Checker object.
Functions¶
jwt_checker_t * jwt_checker_new (void)
Function to create a new checker instance. void jwt_checker_free
(jwt_checker_t *checker)
Frees a previously created checker object. int jwt_checker_error (const
jwt_checker_t *checker)
Checks error state of checker object. const char *
jwt_checker_error_msg (const jwt_checker_t *checker)
Get the error message contained in a checker object. void
jwt_checker_error_clear (jwt_checker_t *checker)
Clear error state in a checker object. int jwt_checker_setkey
(jwt_checker_t *checker, const jwt_alg_t alg, const
jwk_item_t *key)
Sets a key and algorithm for a checker. int jwt_checker_setcb
(jwt_checker_t *checker, jwt_callback_t cb, void *ctx)
Set a callback for generating tokens. void * jwt_checker_getctx
(jwt_checker_t *checker)
Retrieve the callback context that was previously set. int
jwt_checker_verify (jwt_checker_t *checker, const char *token)
Verify a token.
Detailed Description¶
Validating a JWT involves decoding the Base64url parts of the JWT then verifying claims and the signature hash. The checker object allows you to configure how you want to perform these steps so you can easily process tokens with one simple call.
Typedef Documentation¶
typedef struct jwt_checker jwt_checker_t¶
Opaque Checker object.
Function Documentation¶
int jwt_checker_error (const jwt_checker_t * checker)¶
Checks error state of checker object.
Parameters
Returns
void jwt_checker_error_clear (jwt_checker_t * checker)¶
Clear error state in a checker object.
Parameters
const char * jwt_checker_error_msg (const jwt_checker_t * checker)¶
Get the error message contained in a checker object.
Parameters
Returns
void jwt_checker_free (jwt_checker_t * checker)¶
Frees a previously created checker object.
Parameters
void * jwt_checker_getctx (jwt_checker_t * checker)¶
Retrieve the callback context that was previously set. This is useful for accessing the context that was previously passed in the setcb function.
Parameters
Returns
jwt_checker_t * jwt_checker_new (void)¶
Function to create a new checker instance.
Returns
int jwt_checker_setcb (jwt_checker_t * checker, jwt_callback_t cb, void * ctx)¶
Set a callback for generating tokens. When verifying a token, this callback will be run after jwt_t has been parsed, but before the token is verified (including signature verification). During this, the callback should only inspect the header or claims in the JWT. Any attempts to make changes to the jwt_t object will not change the rest of the process.
The callback can also set the key and algorithm used to verify the signature. If the callback returns non-zero, then processing will stop and return an error.
The ctx value is also passed to the callback as part of the jwt_value_t struct.
Note
Parameters
cb Pointer to a callback function
ctx Pointer to data to pass to the callback function
Returns
int jwt_checker_setkey (jwt_checker_t * checker, const jwt_alg_t alg, const jwk_item_t * key)¶
Sets a key and algorithm for a checker. See jwt_builder_setkey for detailed information.
Parameters
alg A valid jwt_alg_t type
key A JWK key object
Returns
int jwt_checker_verify (jwt_checker_t * checker, const char * token)¶
Verify a token.
Note
Parameters
token A string containing a token to be verified
Returns
Author¶
Generated automatically by Doxygen for LibJWT from the source code.
| Version 3.2.2 | LibJWT |