jwt_claims_checker_grp(3)
π jwt_claims_checker_grp(3) π
okay bestie, welcome to the Library Functions Manual for jwt_claims_checker_grp β this is the Checker Functions page, and yes we're about to make JWT validation make sense. no cap. π
πΈ NAME πΈ
jwt_claims_checker_grp β Checker Functions β¨
π¦ SYNOPSIS π¦
the functions (yes, all four, we love a full roster) π
const char * jwt_checker_claim_get (jwt_checker_t *checker, jwt_claims_t type)
int jwt_checker_claim_set (jwt_checker_t *checker, jwt_claims_t type, const char *value)
int jwt_checker_claim_del (jwt_checker_t *checker, jwt_claims_t type)
int jwt_checker_time_leeway (jwt_checker_t *checker, jwt_claims_t claim, time_t secs)
jwt_checker_claim_getβ get the value of a validation claim, bestie. we're reading here. πjwt_checker_claim_setβ set the value of a validation claim. put it there, periodt.jwt_checker_claim_delβ delete the value of a validation claim. gone, not sorry. πjwt_checker_time_leewayβ set up theexpornbfclaim leeway values. giving grace, literally. β¨
π Detailed Description π
so here's the tea: for a checker object, claims get used to verify the token. and ngl, that verification is very simplistic β it only supports standards-defined claims like nbf, iss, etc. even for some of those, LibJWT can only do a simple time comparison or a simple string comparison. likeβ¦ that's it.
fr fr: if you wanted to accept tokens from multiple issuers, you'd have to handle that yourself, most likely in a callback. the library is not doing that for you and honestly? it's not even pretending to. π
here's the list of claims LibJWT can check on its own, plus the method it uses to decide success:
expβ Type: Timestamp β Comparison for Validation:exp > (now + leeway)nbfβ Type: Timestamp β Comparison for Validation:nbf <= (now - leeway)issβ Type: String β Comparison for Validation:!strcmp(iss, userval)audβ Type: String β Comparison for Validation:!strcmp(aud, userval)subβ Type: String β Comparison for Validation:!strcmp(sub, userval)
Note π«Ά the checker object does not evaluate any values in the header β with the one exception of thealgelement when validating a token. anything else you need to do up there can be done in a callback with thejwt_t. so like, do not come for the checker asking about header stuff, it simply does not know her. π
β Function Documentation β
π int jwt_checker_claim_del (jwt_checker_t * checker, jwt_claims_t type)
Delete the value of a validation claim. bye babe π
Parameters
checkerβ Pointer to a checker objecttypeβ One ofJWT_CLAIM_ISS,JWT_CLAIM_AUD, orJWT_CLAIM_SUB
Returns
0on success, any other value is an error
π const char * jwt_checker_claim_get (jwt_checker_t * checker, jwt_claims_t type)
Get the value of a validation claim. we're nosy and we're thriving. β¨
Parameters
checkerβ Pointer to a checker objecttypeβ One ofJWT_CLAIM_ISS,JWT_CLAIM_AUD, orJWT_CLAIM_SUB
Returns
- A string representation of the claim, or
NULLif it isn't set
π int jwt_checker_claim_set (jwt_checker_t * checker, jwt_claims_t type, const char * value)
Set the value of a validation claim. main character move honestly. π
Parameters
checkerβ Pointer to a checker objecttypeβ One ofJWT_CLAIM_ISS,JWT_CLAIM_AUD, orJWT_CLAIM_SUBvalueβ A string to set as the new value of the validation
Returns
0on success, any other value is an error
π int jwt_checker_time_leeway (jwt_checker_t * checker, jwt_claims_t claim, time_t secs)
Setup the exp or nbf claim leeway values. this lets you set a leeway for exp and nbf claims to account for any skew. the value is in seconds. π°οΈ
to disable either one, set the secs to -1.
heads up bestie: -1 is the "actually, no leeway, we're not doing this" button. remember it. π
Parameters
checkerβ Pointer to a checker objectclaimβ One ofJWT_CLAIM_NBForJWT_CLAIM_EXPsecsβ The number of seconds of leeway to account for being valid
Returns
0on success, any other value is an error
π Author π
Generated automatically by Doxygen for LibJWT from the source code.
okay that's the whole page, you ate it, I'm obsessed π«Άπ this was LibJWT, Version 3.3.3, and you were reading jwt_claims_checker_grp(3) β now go validate some tokens responsibly, mwah π
πΈ
π¦ where this page comes from
- ubuntu stonking: libjwt14-doc 3.3.3-1build1 Β· MPL-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms