jwt_claims_checker_grp(3)

πŸ“¦
version 3.3.3 Β· 2 versions
, in ubuntu stonking

πŸ’– 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 the exp or nbf claim 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 the alg element when validating a token. anything else you need to do up there can be done in a callback with the jwt_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 object
  • type β€” One of JWT_CLAIM_ISS, JWT_CLAIM_AUD, or JWT_CLAIM_SUB

Returns

  • 0 on 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 object
  • type β€” One of JWT_CLAIM_ISS, JWT_CLAIM_AUD, or JWT_CLAIM_SUB

Returns

  • A string representation of the claim, or NULL if 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 object
  • type β€” One of JWT_CLAIM_ISS, JWT_CLAIM_AUD, or JWT_CLAIM_SUB
  • value β€” A string to set as the new value of the validation

Returns

  • 0 on 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 object
  • claim β€” One of JWT_CLAIM_NBF or JWT_CLAIM_EXP
  • secs β€” The number of seconds of leeway to account for being valid

Returns

  • 0 on 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