TsgcHTTP_JWT_Client › Properties › JWTOptions

JWTOptions Property

Token configuration: algorithm, signing key material, standard claims and custom header/payload entries.

Syntax

property JWTOptions: TsgcHTTP_JWT_Client_Options read FJWTOptions write SetJWTOptions;

Default Value

Header.alg=jwtHS256; RefreshTokenAfter=0 (token regenerated on every request); all other string/integer claims empty.

Remarks

Publishes everything required to build and sign a JSON Web Token (RFC 7519). The sub-objects map 1:1 to the JWT wire format:

An ML-DSA signature is large, 2420 bytes for ML-DSA-44 and 4627 for ML-DSA-87, so the token grows by roughly 3.2 KB to 6.2 KB of base64url compared with an ES256 one. Check the header size limit of every proxy and server the token passes through before choosing one. See JWT for the algorithm itself and for the AKP JSON Web Key helpers that convert a JWK into the PEM this property takes.

There is no Issuer/Audience/Expiration property at the root of JWTOptions; those RFC 7519 claims are set via Payload.iss, Payload.aud and Payload.exp respectively.

Example


oJWT.JWTOptions.Header.alg := jwtHS256;
oJWT.JWTOptions.Algorithms.HS.Secret := '79F66F1E-E998-436B-8A0A-3E5DEFA4FD9E';
oJWT.JWTOptions.Payload.iss := '2886EC7547B7BA6A9009';
oJWT.JWTOptions.Payload.sub := '1234567890';
oJWT.JWTOptions.Payload.iat := 1630925658;
oJWT.JWTOptions.Payload.exp := 1630933158;
oJWT.JWTOptions.Payload.AddKeyValue('origin', 'www.yourwebsite.com');
oJWT.JWTOptions.RefreshTokenAfter := 60 * 40;

// Post-quantum signatures, no OpenSSL involved
oJWT.JWTOptions.Header.alg := jwtMLDSA65;
oJWT.JWTOptions.Algorithms.MLDSA.PrivateKey.Text :=
  '-----BEGIN PRIVATE KEY-----' + sLineBreak +
  'MFICAQAwCwYJYIZIAWUDBAMSBECy...' + sLineBreak +
  '-----END PRIVATE KEY-----';
oJWT.JWTOptions.Payload.sub := '1234567890';

Back to Properties