l8w8jwt_encoding_params

Struct containing the parameters to use for creating a JWT with l8w8jwt.

Members

Variables

additional_header_claims
l8w8jwt_claim* additional_header_claims;

OPTIONAL Array of additional claims to include in the JWT's header like for example "kid" or "cty"; pass <code>NULL</code> if you don't wish to add any! <p> Avoid header claims such as <code>typ</code> and <code>alg</code>, since those are written by the encoding function itself. @see https://tools.ietf.org/html/rfc7519#section-4.1.7

additional_header_claims_count
size_t additional_header_claims_count;

OPTIONAL The additional_header_claims array size; pass <code>0</code> if you don't wish to include any custom claims!

additional_payload_claims
l8w8jwt_claim* additional_payload_claims;

OPTIONAL Array of additional claims to include in the JWT's payload; pass <code>NULL</code> if you don't wish to add any! <p> 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! @see https://tools.ietf.org/html/rfc7519#section-4

additional_payload_claims_count
size_t additional_payload_claims_count;

OPTIONAL The additional_payload_claims array size; pass <code>0</code> if you don't wish to include any custom claims!

alg
int alg;

The signature algorithm ID. <p> [0;2] = HS256/384/512 | [3;5] = RS256/384/512 | [6;8] = PS256/384/512 | [9;11] = ES256/384/512

aud
char* aud;

OPTIONAL The audience claim (who is the JWT intended for? Who is the intended JWT's recipient?). Set this to <code>NULL</code> if you don't wish to add this claim to the token. @see https://tools.ietf.org/html/rfc7519#section-4.1.3

aud_length
size_t aud_length;

aud claim string length.

exp
time_t exp;

Expiration time claim; specifies when this token should stop being valid (in seconds since Unix epoch). <p> If you want to omit this, set this to <code>0</code>, 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. @see https://tools.ietf.org/html/rfc7519#section-4.1.4

iat
time_t iat;

"Issued at" timestamp claim; specifies when this token was emitted (in seconds since Unix epoch). <p> If you want to omit this, set this to <code>0</code>, 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. @see https://tools.ietf.org/html/rfc7519#section-4.1.6

iss
char* iss;

OPTIONAL The issuer claim (who issued the JWT?). Can be omitted by setting this to <code>NULL</code>. @see https://tools.ietf.org/html/rfc7519#section-4.1.1

iss_length
size_t iss_length;

iss claim string length.

jti
char* jti;

OPTIONAL The JWT ID. Provides a unique identifier for the token. Can be omitted by setting this to <code>NULL</code>. @see https://tools.ietf.org/html/rfc7519#section-4.1.7

jti_length
size_t jti_length;

jti claim string length.

nbf
time_t nbf;

"Not before" time claim; specifies when this token should start being valid (in seconds since Unix epoch). <p> If you want to omit this, set this to <code>0</code>, 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. @see https://tools.ietf.org/html/rfc7519#section-4.1.5

out_
char** out_;

Where the encoded token should be written into (will be malloc'ed, so make sure to <code>l8w8jwt_free()</code> this as soon as you're done using it!).

out_length
size_t* out_length;

Where the output token string length should be written into.

secret_key
ubyte* 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...).

secret_key_length
size_t secret_key_length;

Length of the secret_key

secret_key_pw
ubyte* secret_key_pw;

If the secret key requires a password for usage, please assign it to this field. <p> You can only omit this when using JWT algorithms "HS256", "HS384" or "HS512" (it's ignored in that case actually). <p> Every other algorithm requires you to at least set this to <code>NULL</code> if the {@link #secret_key} isn't password-protected.

secret_key_pw_length
size_t secret_key_pw_length;

The secret key's password length (if there is any). If there's none, set this to zero!

sub
char* sub;

OPTIONAL The subject claim (who is the JWT about?). Set to <code>NULL</code> if you don't want it in your token. @see https://tools.ietf.org/html/rfc7519#section-4.1.2

sub_length
size_t sub_length;

sub claim string length.

Meta