TsgcHTTP_JWT_Server › Properties › JWTOptions

JWTOptions Property

Server-side validator configuration: enabled signing algorithms (HS/RS/ES/ML-DSA) with their Secret or PublicKey, plus registered-claim validations (iat, nbf, exp) and the clock skew allowed.

Syntax

property JWTOptions: TsgcHTTP_JWT_Server_Options read FJWTOptions write SetJWTOptions;

Default Value

All four algorithm families enabled (HS.Enabled, RS.Enabled, ES.Enabled, MLDSA.Enabled = True); HS.Secret empty, RS.PublicKey, ES.PublicKey and MLDSA.PublicKey empty; Validations.Expiration, Validations.Issued, Validations.NotBefore = True; Validations.Leeway = 60.

Remarks

Mirror of TsgcHTTP_JWT_Client.JWTOptions from the validator perspective — instead of signing material, it holds the verification material and the checks to apply to an incoming token. Sub-objects:

Verifying an ML-DSA signature is pure Object Pascal from the sgcCrypto pack, so it needs no OpenSSL library. In a build without that pack the MLDSA options still exist, so a form stored with them still loads, but every ML-DSA token is rejected with "ML-DSA Algorithm not supported, it needs the sgcCrypto pack". See JWT for the algorithms themselves.

Issuer, Audience and any other custom claims are not validated automatically; subscribe to OnJWTAfterValidateToken to inspect the decoded Payload and flip the Valid flag based on your own business rules.

Example


// Accept only RS256 tokens signed by a known authority
oJWT.JWTOptions.Algorithms.HS.Enabled := False;
oJWT.JWTOptions.Algorithms.ES.Enabled := False;
oJWT.JWTOptions.Algorithms.RS.Enabled := True;
oJWT.JWTOptions.Algorithms.RS.PublicKey.Text :=
  '-----BEGIN PUBLIC KEY-----' + sLineBreak +
  'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...' + sLineBreak +
  '-----END PUBLIC KEY-----';

// Standard claim checks
oJWT.JWTOptions.Validations.Expiration := True;
oJWT.JWTOptions.Validations.Issued := True;
oJWT.JWTOptions.Validations.NotBefore := True;
// Allow 60 seconds of clock skew between this server and the issuer
oJWT.JWTOptions.Validations.Leeway := 60;

// Accept only post-quantum ML-DSA tokens
oJWT.JWTOptions.Algorithms.HS.Enabled := False;
oJWT.JWTOptions.Algorithms.RS.Enabled := False;
oJWT.JWTOptions.Algorithms.ES.Enabled := False;
oJWT.JWTOptions.Algorithms.MLDSA.Enabled := True;
oJWT.JWTOptions.Algorithms.MLDSA.PublicKey.Text :=
  '-----BEGIN PUBLIC KEY-----' + sLineBreak +
  'MIIFMjALBglghkgBZQMEAxIDggUhAA...' + sLineBreak +
  '-----END PUBLIC KEY-----';

Back to Properties