JWT Server

Server-side JWT validation. Plug TsgcHTTP_JWT_Server into a TsgcWebSocketHTTPServer to verify Authorization Bearer tokens before dispatching requests.

TsgcHTTP_JWT_Server

Verifies inbound JWTs against your signing keys (HMAC, RSA, ECDSA, EdDSA), checks exp/nbf/aud/iss claims and rejects mismatched tokens with a typed event for the application layer.

Komponentenklasse

TsgcHTTP_JWT_Server

Protokoll

RFC 7519 (JWT)

Plattformen

Windows, macOS, Linux, iOS, Android

Edition

Enterprise

Drop, attach to server, verify on every request

Drop a TsgcHTTP_JWT_Server, configure the verifying keys (or a JWKS URL) and attach to TsgcWebSocketHTTPServer.JWT — all incoming requests are validated automatically.

uses
  sgcWebSocket, sgcHTTP;

var
  Server: TsgcWebSocketHTTPServer;
  JWT: TsgcHTTP_JWT_Server;
begin
  JWT := TsgcHTTP_JWT_Server.Create(nil);
  JWT.JWTOptions.Algorithms.HS.Secret := 'shared-secret';
  JWT.JWTOptions.Verify.Issuer   := 'auth.example.com';
  JWT.JWTOptions.Verify.Audience := 'api.example.com';

  Server := TsgcWebSocketHTTPServer.Create(nil);
  Server.Port := 8443;
  Server.SSL  := True;
  Server.Authentication.JWT.Enabled := True;
  Server.Authentication.JWT.Server  := JWT;

  Server.Active := True;
end;
// uses: sgcWebSocket, sgcHTTP
TsgcHTTP_JWT_Server *JWT = new TsgcHTTP_JWT_Server(this);
JWT->JWTOptions->Algorithms->HS->Secret = "shared-secret";

TsgcWebSocketHTTPServer *Server = new TsgcWebSocketHTTPServer(this);
Server->Authentication->JWT->Enabled = true;
Server->Authentication->JWT->Server  = JWT;
Server->Active = true;

Was steckt drin

Server-side JWT verifier that integrates directly with TsgcWebSocketHTTPServer and TsgcWebSocketServer authentication.

Multi-algorithm verify

Supports HS256/384/512, RS256/384/512, ES256/384/512, PS256/384/512 and EdDSA. Multiple keys (kid-indexed) can be loaded for key rotation.

Standard claim checks

Verify.Issuer, Verify.Audience, Verify.Subject, Verify.NotBefore, Verify.ExpirationTime are all enforced against the inbound payload by default.

JWKS endpoint

Point JWTOptions.JWKS.URL at an issuer JWKS endpoint — the component fetches the public keys, caches them and rotates per the JWK kid in each token header.

On-failure event

OnAuthError exposes the rejection reason (signature mismatch, expired, audience mismatch); your app decides whether to 401 or fall back.

WebSocket hooks

Works for TsgcWebSocketServer too — the WebSocket upgrade carries the Authorization header, the JWT server verifies before OnConnect fires.

JWE support

Encrypted JWE tokens are decoded and verified inline using the configured private key (RSA-OAEP, ECDH-ES key wrap; AES-CBC / AES-GCM content encryption).

Spezifikationen & Referenzen

Maßgebliche Quellen für die Standards, die diese Komponente implementiert.

Dokumentation & Demos

Springe direkt zur Komponentenreferenz, lade das einsatzbereite Demo-Projekt herunter und teste die Testversion.

Online Help — TsgcHTTP_JWT_Server Vollständige Eigenschaften-, Methoden- und Ereignisreferenz für diese Komponente.
Demo Project — Demos\20.HTTP_Protocol\05.JWT Einsatzbereites Beispielprojekt. Im sgcWebSockets-Paket enthalten — lade unten die Testversion herunter.
Technisches Dokument (PDF) Funktionen, Schnellstart, Codebeispiele für Delphi & C++ Builder und Primärquellenreferenzen — nur für diese Komponente.
Benutzerhandbuch (PDF) Umfassendes Handbuch zu jeder Komponente der Bibliothek.

Ready to Verify JWTs Server-side?

Download the free trial and add JWT validation to your Delphi servers.