jwt_checker_grp(3)

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

πŸ’– jwt_checker_grp(3) πŸ’–

okay bestie, so we're in the Library Functions Manual rn and today's main character is the checker β€” literally the thing that goes "hold up, is this JWT actually real?" πŸ•΅οΈβ™€οΈβœ¨


✨ NAME ✨

jwt_checker_grp β€” Checker πŸ’…


🌸 SYNOPSIS 🌸

πŸŽ€ Typedefs

  • typedef struct jwt_checker jwt_checker_t β€” the Opaque Checker object. it's giving mysterious, it's giving "you don't get to see inside me" 🫢

πŸ¦‹ Functions

jwt_checker_t * jwt_checker_new (void)

Function to create a new checker instance. baby's first checker 🍼

void jwt_checker_free (jwt_checker_t *checker)

Frees a previously created checker object. we do NOT leave it hanging, periodt.

int jwt_checker_error (const jwt_checker_t *checker)

Checks error state of checker object. vibe check but for errors πŸ’€

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. therapy for your checker 🧚

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. the moment we've all been waiting for πŸ”₯


πŸ’« 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.

no cap, that's the whole glow-up: you set it up once, and then you just... call it. one call. iconic behavior πŸ‘‘


🌈 Typedef Documentation 🌈

typedef struct jwt_checker jwt_checker_t

Opaque Checker object. we love a mystery, we respect the privacy 🫢


⭐ Function Documentation ⭐

int jwt_checker_error (const jwt_checker_t * checker)

Checks error state of checker object.

Parameters

  • checker β€” Pointer to a checker object

Returns

  • 0 if no errors exist, non-zero otherwise

void jwt_checker_error_clear (jwt_checker_t * checker)

Clear error state in a checker object.

Parameters

  • checker β€” Pointer to a checker object

const char * jwt_checker_error_msg (const jwt_checker_t * checker)

Get the error message contained in a checker object.

Parameters

  • checker β€” Pointer to a checker object

Returns

  • Pointer to a string with the error message. Can be an empty string if there is no error. Never returns NULL.
fr fr, never NULL. that's a promise bestie. you can always print it, no if (msg) needed πŸ’…

void jwt_checker_free (jwt_checker_t * checker)

Frees a previously created checker object.

Parameters

  • checker β€” Pointer to a checker object

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

  • checker β€” Pointer to a checker object

Returns

  • Pointer to the context or NULL

jwt_checker_t * jwt_checker_new (void )

Function to create a new checker instance.

Returns

  • Pointer to a checker object on success, NULL on failure

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.

so like, timing matters bestie: parsed βœ… β†’ your callback runs πŸ‘€ β†’ THEN it gets verified. and during that little window you're only looking, not touching. any edits you make to the jwt_t object? yeah those do not change the rest of the process. nada. 😭

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 Calling this with a NULL cb param and a new ctx param after already setting the callback will allow updating the ctx passed to the callback. Calling with both values as NULL will disable the callback completely.

Parameters

  • checker β€” Pointer to a checker object
  • cb β€” Pointer to a callback function
  • ctx β€” Pointer to data to pass to the callback function

Returns

  • 0 on success, non-zero otherwise with error set in the checker

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

  • checker β€” Pointer to a checker object
  • alg β€” A valid jwt_alg_t type
  • key β€” A JWK key object

Returns

  • 0 on success, non-zero otherwise with error set in the checker

int jwt_checker_verify (jwt_checker_t * checker, const char * token)

Verify a token.

Note If you set a callback for this checker, this is when it will be called.

this is it. the moment. the finale. 🎬 if you set a callback, THIS is when it fires, so don't say I didn't warn you 🫢

Parameters

  • checker β€” Pointer to a checker object
  • token β€” A string containing a token to be verified

Returns

  • 0 on success, non-zero otherwise with error set in the checker

🫢 Author 🫢

Generated automatically by Doxygen for LibJWT from the source code. not a human writing this, just Doxygen doing its little robot thing πŸ€–βœ¨


okay and that's the whole page bestie!! this was LibJWT, Version 3.3.3, and you just read jwt_checker_grp(3) β€” tysm for coming to my TED talk, go forth and verify those tokens responsibly πŸ’–πŸŽ€πŸ¦‹ no cap, you ate. periodt πŸ’…πŸŒˆβ­

πŸ“¦ where this page comes from