LibJWT Dev
The C JSON Web Token Library +JWK +JWKS
Token Verification
Collaboration diagram for Token Verification:

Functions

int jwt_verify (jwt_t **jwt, const char *token, jwt_config_t *config)
 Decode and verify a JWT.
 
int jwt_verify_wcb (jwt_t **jwt, const char *token, jwt_config_t *config, jwt_callback_t cb)
 Decode and verify a JWT, with user callback.
 
int jwt_decode (jwt_t **jwt, const char *token, const unsigned char *key, int key_len)
 Decode a JWT.
 
int jwt_decode_2 (jwt_t **jwt, const char *token, jwt_callback_t cb)
 Decode a JWT with a user provided callback.
 

Detailed Description

Function Documentation

◆ jwt_decode()

int jwt_decode ( jwt_t ** jwt,
const char * token,
const unsigned char * key,
int key_len )

Decode a JWT.

Deprecated
See jwt_verify instead.
Parameters
jwtPointer to a JWT object pointer
tokenPointer to a nil terminated JWT string
keyPointer to key
key_lenThe length of the above key.
Returns
0 on success, or an errno. On success, jwt will be allocated

◆ jwt_decode_2()

int jwt_decode_2 ( jwt_t ** jwt,
const char * token,
jwt_callback_t cb )

Decode a JWT with a user provided callback.

Deprecated
See jwt_verify_wcb instead.
Parameters
jwtPointer to a JWT object pointer
tokenPointer to a nil terminated JWT string
cbPointer to a callback
Returns
0 on success, or an errno. On success, jwt will be allocated

◆ jwt_verify()

int jwt_verify ( jwt_t ** jwt,
const char * token,
jwt_config_t * config )

Decode and verify a JWT.

Parameters
jwtPointer to a JWT object pointer
tokenPointer to a nil terminated JWT string
configPointer to a config structure to define how to verify the token
Returns
0 on success, or an errno. On success, jwt will be allocated

◆ jwt_verify_wcb()

int jwt_verify_wcb ( jwt_t ** jwt,
const char * token,
jwt_config_t * config,
jwt_callback_t cb )

Decode and verify a JWT, with user callback.

This operates the same as jwt_verify, with the addition of calling a user defined callback function between the decode and verification step. This allows the user to perform some extra verification, and even provide a key after decoding (e.g. to match a "kid").

Parameters
jwtPointer to a JWT object pointer
tokenPointer to a nil terminated JWT string
configPointer to a config structure to define how to verify the token
cbPointer to a callback
Returns
0 on success, or an errno. On success, jwt will be allocated