l8w8jwt
|
#include <encode.h>
Public Attributes | |
int | alg |
char * | iss |
size_t | iss_length |
char * | sub |
size_t | sub_length |
char * | aud |
size_t | aud_length |
char * | jti |
size_t | jti_length |
l8w8jwt_time_t | exp |
l8w8jwt_time_t | nbf |
l8w8jwt_time_t | iat |
struct l8w8jwt_claim * | additional_header_claims |
size_t | additional_header_claims_count |
struct l8w8jwt_claim * | additional_payload_claims |
size_t | additional_payload_claims_count |
unsigned char * | secret_key |
size_t | secret_key_length |
unsigned char * | secret_key_pw |
size_t | secret_key_pw_length |
char ** | out |
size_t * | out_length |
Struct containing the parameters to use for creating a JWT with l8w8jwt.
struct l8w8jwt_claim* l8w8jwt_encoding_params::additional_header_claims |
[OPTIONAL] Array of additional claims to include in the JWT's header like for example "kid" or "cty"; pass NULL
if you don't wish to add any!
Avoid header claims such as typ
and alg
, since those are written by the encoding function itself.
size_t l8w8jwt_encoding_params::additional_header_claims_count |
[OPTIONAL] The additional_header_claims array size; pass 0
if you don't wish to include any custom claims!
struct l8w8jwt_claim* l8w8jwt_encoding_params::additional_payload_claims |
[OPTIONAL] Array of additional claims to include in the JWT's payload; pass NULL
if you don't wish to add any!
Registered claim names such as "iss", "exp", etc... have their own dedicated field within this struct: do not include those in this array to prevent uncomfortable duplicates!
size_t l8w8jwt_encoding_params::additional_payload_claims_count |
[OPTIONAL] The additional_payload_claims array size; pass 0
if you don't wish to include any custom claims!
int l8w8jwt_encoding_params::alg |
The signature algorithm ID.
[0;2] = HS256/384/512 | [3;5] = RS256/384/512 | [6;8] = PS256/384/512 | [9;11] = ES256/384/512
char* l8w8jwt_encoding_params::aud |
[OPTIONAL] The audience claim (who is the JWT intended for? Who is the intended JWT's recipient?). Set this to NULL
if you don't wish to add this claim to the token.
size_t l8w8jwt_encoding_params::aud_length |
aud claim string length.
l8w8jwt_time_t l8w8jwt_encoding_params::exp |
Expiration time claim; specifies when this token should stop being valid (in seconds since Unix epoch).
If you want to omit this, set this to 0
, but do NOT FORGET to set it to something, otherwise it will be set to whatever random value was in the memory where this variable resides.
l8w8jwt_time_t l8w8jwt_encoding_params::iat |
"Issued at" timestamp claim; specifies when this token was emitted (in seconds since Unix epoch).
If you want to omit this, set this to 0
, but do NOT FORGET to set it to something, otherwise it will be set to whatever random value was in the memory where this variable resides.
char* l8w8jwt_encoding_params::iss |
[OPTIONAL] The issuer claim (who issued the JWT?). Can be omitted by setting this to NULL
.
size_t l8w8jwt_encoding_params::iss_length |
iss claim string length.
char* l8w8jwt_encoding_params::jti |
[OPTIONAL] The JWT ID. Provides a unique identifier for the token. Can be omitted by setting this to NULL
.
size_t l8w8jwt_encoding_params::jti_length |
jti claim string length.
l8w8jwt_time_t l8w8jwt_encoding_params::nbf |
"Not before" time claim; specifies when this token should start being valid (in seconds since Unix epoch).
If you want to omit this, set this to 0
, but do NOT FORGET to set it to something, otherwise it will be set to whatever random value was in the memory where this variable resides.
char** l8w8jwt_encoding_params::out |
Where the encoded token should be written into (will be malloc'ed, so make sure to l8w8jwt_free()
this as soon as you're done using it!).
size_t* l8w8jwt_encoding_params::out_length |
Where the output token string length should be written into.
unsigned char* l8w8jwt_encoding_params::secret_key |
The secret key to use for signing the token (e.g. if you chose HS256 as algorithm, this will be the HMAC secret; for RS512 this will be the private PEM-formatted RSA key string, and so on...).
size_t l8w8jwt_encoding_params::secret_key_length |
Length of the secret_key
unsigned char* l8w8jwt_encoding_params::secret_key_pw |
If the secret key requires a password for usage, please assign it to this field.
You can only omit this when using JWT algorithms "HS256", "HS384" or "HS512" (it's ignored in that case actually).
Every other algorithm requires you to at least set this to NULL
if the secret_key
isn't password-protected.
size_t l8w8jwt_encoding_params::secret_key_pw_length |
The secret key's password length (if there is any). If there's none, set this to zero!
char* l8w8jwt_encoding_params::sub |
[OPTIONAL] The subject claim (who is the JWT about?). Set to NULL
if you don't want it in your token.
size_t l8w8jwt_encoding_params::sub_length |
sub claim string length.