LibJWT Dev
The C JSON Web Token Library +JWK +JWKS
|
These functions allow you to add, remove and retrieve grants from a JWT object. More...
Functions | |
const char * | jwt_get_grant (jwt_t *jwt, const char *grant) |
Return the value of a string grant. | |
long | jwt_get_grant_int (jwt_t *jwt, const char *grant) |
Return the value of an integer grant. | |
int | jwt_get_grant_bool (jwt_t *jwt, const char *grant) |
Return the value of an boolean grant. | |
char * | jwt_get_grants_json (jwt_t *jwt, const char *grant) |
Return the value of a grant as JSON encoded object string. | |
int | jwt_add_grant (jwt_t *jwt, const char *grant, const char *val) |
Add a new string grant to this JWT object. | |
int | jwt_add_grant_int (jwt_t *jwt, const char *grant, long val) |
Add a new integer grant to this JWT object. | |
int | jwt_add_grant_bool (jwt_t *jwt, const char *grant, int val) |
Add a new boolean grant to this JWT object. | |
int | jwt_add_grants_json (jwt_t *jwt, const char *json) |
Add grants from a JSON encoded object string. | |
int | jwt_del_grants (jwt_t *jwt, const char *grant) |
Delete a grant from this JWT object. | |
These functions allow you to add, remove and retrieve grants from a JWT object.
int jwt_add_grant | ( | jwt_t * | jwt, |
const char * | grant, | ||
const char * | val ) |
Add a new string grant to this JWT object.
Creates a new grant for this object. The string for grant and val are copied internally, so do not require that the pointer or string remain valid for the lifetime of this object. It is an error if you try to add a grant that already exists.
jwt | Pointer to a JWT object. |
grant | String containing the name of the grant to add. |
val | String containing the value to be saved for grant. Can be an empty string, but cannot be NULL. |
int jwt_add_grant_bool | ( | jwt_t * | jwt, |
const char * | grant, | ||
int | val ) |
Add a new boolean grant to this JWT object.
Creates a new grant for this object. The string for grant is copied internally, so do not require that the pointer or string remain valid for the lifetime of this object. It is an error if you try to add a grant that already exists.
jwt | Pointer to a JWT object. |
grant | String containing the name of the grant to add. |
val | boolean containing the value to be saved for grant. |
int jwt_add_grant_int | ( | jwt_t * | jwt, |
const char * | grant, | ||
long | val ) |
Add a new integer grant to this JWT object.
Creates a new grant for this object. The string for grant is copied internally, so do not require that the pointer or string remain valid for the lifetime of this object. It is an error if you try to add a grant that already exists.
jwt | Pointer to a JWT object. |
grant | String containing the name of the grant to add. |
val | int containing the value to be saved for grant. |
int jwt_add_grants_json | ( | jwt_t * | jwt, |
const char * | json ) |
Add grants from a JSON encoded object string.
Loads a grant from an existing JSON encoded object string. Overwrites existing grant. If grant is NULL, then the JSON encoded string is assumed to be a JSON hash of all grants being added and will be merged into the grant listing.
jwt | Pointer to a JWT object. |
json | String containing a JSON encoded object of grants. |
int jwt_del_grants | ( | jwt_t * | jwt, |
const char * | grant ) |
Delete a grant from this JWT object.
Deletes the named grant from this object. It is not an error if there is no grant matching the passed name. If grant is NULL, then all grants are deleted from this JWT.
jwt | Pointer to a JWT object. |
grant | String containing the name of the grant to delete. If this is NULL, then all grants are deleted. |
const char * jwt_get_grant | ( | jwt_t * | jwt, |
const char * | grant ) |
Return the value of a string grant.
Returns the string value for a grant (e.g. "iss"). If it does not exist, NULL will be returned.
jwt | Pointer to a JWT object. |
grant | String containing the name of the grant to return a value for. |
int jwt_get_grant_bool | ( | jwt_t * | jwt, |
const char * | grant ) |
Return the value of an boolean grant.
Returns the int value for a grant (e.g. "exp"). If it does not exist, 0 will be returned.
jwt | Pointer to a JWT object. |
grant | String containing the name of the grant to return a value for. |
long jwt_get_grant_int | ( | jwt_t * | jwt, |
const char * | grant ) |
Return the value of an integer grant.
Returns the int value for a grant (e.g. "exp"). If it does not exist, 0 will be returned.
jwt | Pointer to a JWT object. |
grant | String containing the name of the grant to return a value for. |
char * jwt_get_grants_json | ( | jwt_t * | jwt, |
const char * | grant ) |
Return the value of a grant as JSON encoded object string.
Returns the JSON encoded string value for a grant (e.g. "iss"). If it does not exist, NULL will be returned.
jwt | Pointer to a JWT object. |
grant | String containing the name of the grant to return a value for. If this is NULL, all grants will be returned as a JSON encoded hash. |