eSeGeCe
software
The sgcWebSockets library supports multiple authentication methods to secure WebSocket communication in Delphi and C++Builder applications. Since the WebSocket protocol itself doesn't define an authentication mechanism, sgcWebSockets implements its own set of techniques suitable for both server and client sides.
Supported Authentication TypesThe library supports the following main authentication methods:
The client performs an HTTP GET request to receive a session token:
http://host:port/sgc/req/auth/session/:user/:password
The server responds with a token, which is then used in the WebSocket URL:
ws://host:port/sgc/auth/session/:token
Properties
Authentication.Enabled := True;
Advantages
Example
Client.URL := 'ws://localhost:443/sgc/auth/session/your-token';
Credentials are included directly in the WebSocket URL:
ws://host:port/sgc/auth/url/username/password
Advantages
Disadvantages
Uses the standard HTTP Authorization header:
Authorization: Basic base64(user:password)
Properties
Authentication.AuthUsers := 'user=password';
Use the OnAuthentication event for custom validation.
Example
procedure WSServerAuthentication(Connection: TsgcWSConnection; aUser, aPassword: string; var Authenticated: Boolean);
begin
if (aUser = 'John') and (aPassword = '1234') then
Authenticated := True;
end;
OAuth2 is supported through components such as TsgcHTTP_OAuth2_Server and TsgcHTTP_OAuth2_Client.
It works with providers like Google, Microsoft, Azure AD, and custom identity systems.
Authentication is performed using JSON Web Tokens (JWT). Tokens can be passed either in the query string or in HTTP headers.
PropertiesAuthentication.TokenParam := srctQuery
Authentication.TokenParam := srctHeader
Components: TsgcHTTP_JWT_Client, TsgcHTTP_JWT_Server
AdvantagesWebAuthn is based on the FIDO2 standard and uses public key cryptography. It enables passwordless authentication.
ComponentsTsgcWSAPIServer_WebAuthn
AdvantagesWhen you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.