l8w8jwt
Loading...
Searching...
No Matches
Classes | Macros | Functions
claim.h File Reference

JWT claims as described in https://auth0.com/docs/tokens/concepts/jwt-claims. More...

#include "version.h"
#include <stdlib.h>
Include dependency graph for claim.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  l8w8jwt_claim
 

Macros

#define L8W8JWT_CLAIM_TYPE_STRING   0
 
#define L8W8JWT_CLAIM_TYPE_INTEGER   1
 
#define L8W8JWT_CLAIM_TYPE_NUMBER   2
 
#define L8W8JWT_CLAIM_TYPE_BOOLEAN   3
 
#define L8W8JWT_CLAIM_TYPE_NULL   4
 
#define L8W8JWT_CLAIM_TYPE_ARRAY   5
 
#define L8W8JWT_CLAIM_TYPE_OBJECT   6
 
#define L8W8JWT_CLAIM_TYPE_OTHER   7
 

Functions

L8W8JWT_API void l8w8jwt_free_claims (struct l8w8jwt_claim *claims, size_t claims_count)
 
L8W8JWT_API int l8w8jwt_write_claims (struct chillbuff *stringbuilder, struct l8w8jwt_claim *claims, size_t claims_count)
 
L8W8JWT_API struct l8w8jwt_claiml8w8jwt_get_claim (struct l8w8jwt_claim *claims, size_t claims_count, const char *key, size_t key_length)
 

Detailed Description

JWT claims as described in https://auth0.com/docs/tokens/concepts/jwt-claims.

Author
Raphael Beck

Macro Definition Documentation

◆ L8W8JWT_CLAIM_TYPE_ARRAY

#define L8W8JWT_CLAIM_TYPE_ARRAY   5

JWT claim value type JSON array (e.g. "ids": [2, 4, 8, 16]).

◆ L8W8JWT_CLAIM_TYPE_BOOLEAN

#define L8W8JWT_CLAIM_TYPE_BOOLEAN   3

JWT claim value is a boolean (e.g. "done": true).

◆ L8W8JWT_CLAIM_TYPE_INTEGER

#define L8W8JWT_CLAIM_TYPE_INTEGER   1

JWT claim value is an integer (e.g. "exp": 1579610629)

◆ L8W8JWT_CLAIM_TYPE_NULL

#define L8W8JWT_CLAIM_TYPE_NULL   4

JWT claim value is null (e.g. "ref": null).

◆ L8W8JWT_CLAIM_TYPE_NUMBER

#define L8W8JWT_CLAIM_TYPE_NUMBER   2

JWT claim value type number (e.g. "size": 1.85).

◆ L8W8JWT_CLAIM_TYPE_OBJECT

#define L8W8JWT_CLAIM_TYPE_OBJECT   6

JWT claim value type is a JSON object (e.g. "objs": { "name": "GMan", "id": 420 }).

◆ L8W8JWT_CLAIM_TYPE_OTHER

#define L8W8JWT_CLAIM_TYPE_OTHER   7

JWT claim value is some other type.

◆ L8W8JWT_CLAIM_TYPE_STRING

#define L8W8JWT_CLAIM_TYPE_STRING   0

JWT claim value is a string (e.g. "iss": "glitchedpolygons.com").

Function Documentation

◆ l8w8jwt_free_claims()

L8W8JWT_API void l8w8jwt_free_claims ( struct l8w8jwt_claim claims,
size_t  claims_count 
)

Frees a heap-allocated l8w8jwt_claim array.

Parameters
claimsThe claims to free.
claims_countThe size of the passed claims array.

◆ l8w8jwt_get_claim()

L8W8JWT_API struct l8w8jwt_claim * l8w8jwt_get_claim ( struct l8w8jwt_claim claims,
size_t  claims_count,
const char *  key,
size_t  key_length 
)

Gets a claim by key from a l8w8jwt_claim array.

Parameters
claimsThe array to look in.
claims_countThe claims array size.
keyThe claim key (e.g. "sub") to look for.
key_lengthThe claim key's string length.
Returns
The found claim; NULL if no such claim was found in the array.

◆ l8w8jwt_write_claims()

L8W8JWT_API int l8w8jwt_write_claims ( struct chillbuff *  stringbuilder,
struct l8w8jwt_claim claims,
size_t  claims_count 
)

Writes a bunch of JWT claims into a chillbuff stringbuilder.

Curly braces and trailing commas won't be written; only the "key":"value" pairs!

Parameters
stringbuilderThe buffer into which to write the claims.
claimsThe l8w8jwt_claim array of claims to write.
claims_countThe claims array size.
Returns
Return code as specified inside retcodes.h