TsgcWebSocketHTTPServerProprietà › Authentication

Authentication Proprietà

Abilita e configura l'autenticazione utente/password per le connessioni WebSocket e HTTP in entrata.

Sintassi

property Authentication: TsgcWSAuthenticationServer_Options read FAuthentication write SetAuthentication;

Valore predefinito

Enabled=False

Note

Quando Authentication.Enabled è True, il server autentica ogni connessione in ingresso rispetto all'elenco AuthUsers (formato utente=password per riga). Sono supportati tre schemi predefiniti: Session (il client esegue prima una GET HTTP, riceve un id di sessione e poi apre il WebSocket passando l'id come parametro), URL (nome utente e password vengono inviati nella query string dell'handshake WebSocket) e Basic (HTTP Basic Access Authentication — utilizzata solo da client/server VCL e richieste HTTP). L'evento OnAuthentication consente di aggiungere una propria verifica delle credenziali; OnUnknownAuthentication gestisce schemi non standard come Bearer/JWT. Utilizzare CustomHeaders per aggiungere intestazioni HTTP extra restituite in caso di errori di autenticazione.

Esempio


oServer := TsgcWebSocketHTTPServer.Create(nil);
oServer.Authentication.Enabled := true;
oServer.Authentication.Basic.Enabled := true;
oServer.Authentication.AuthUsers.Add('user=secret');
oServer.Active := true;

Torna alle Proprietà