sgcWebSockets Autorizzazioni

· Funzionalità

The sgcWebSockets libreria supporta multiple autenticazione metodi a secure WebSocket communication in Delphi e C++Builder applications. Poiché il WebSocket protocol itself non define an autenticazione mechanism, sgcWebSockets implementa il suo own impostare di techniques suitable per entrambi server e client sides.

Supported Autenticazione Types

The libreria supporta il seguente principale autenticazione methods:

  1. Session Autenticazione
  2. URL Autenticazione
  3. Basic Autenticazione
  4. OAuth2
  5. JWT (JSON Web Tokens)
  6. WebAuthn (Web Autenticazione)

1. Session Autenticazione

 The client performs an HTTP GET richiesta a ricevere a session token:

http://host:port/sgc/req/auth/session/:user/:password

The server responds con a token, che è poi utilizzato in il 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';

2. URL Autenticazione

Credentials sono included directly in il WebSocket URL: 

ws://host:port/sgc/auth/url/username/password

Advantages

Disadvantages

3. Basic Autenticazione

Uses il standard HTTP Authorization header:

Authorization: Basic base64(user:password)

Properties

Authentication.AuthUsers := 'user=password';

Use il OnAuthentication evento per custom validation.

Advantages

Example

procedure WSServerAuthentication(Connection: TsgcWSConnection; aUser, aPassword: string; var Authenticated: Boolean);
begin
  se (aUser = 'John') e (aPassword = '1234') then
    Authenticated := True;

end;

4. OAuth2 Autenticazione

OAuth2 è supportati attraverso componenti come TsgcHTTP_OAuth2_Server e TsgcHTTP_OAuth2_Client.
It works con providers like Google, Microsoft, Azure AD, e custom identity systems.

Key Events Advantages


5. JWT Autenticazione

Authentication è performed utilizzando JSON Web Tokens (JWT). Tokens può essere passed sia in il query string o in HTTP headers.

Properties

Authentication.TokenParam := srctQuery
Autenticazione.TokenParam := srctHeader

Components: TsgcHTTP_JWT_Client, TsgcHTTP_JWT_Server

Advantages

6. WebAuthn Autenticazione

WebAuthn è based su il FIDO2 standard e utilizza public chiave cryptography. It abilita passwordless authentication.

Components

TsgcWSAPIServer_WebAuthn

Advantages

7. Comparison Table