TsgcWebSocketServer_HTTPAPIプロパティ › Authentication

Authentication プロパティ

受信するWebSocketおよびHTTP要求に対して、ユーザー/パスワード認証を有効にして設定します。

構文

property Authentication: TsgcWSAuthenticationServer_Options read FAuthentication write SetAuthentication;

デフォルト値

Enabled=False

解説

Authentication.EnabledTrueの場合、サーバーはすべての受信接続をAuthUsersリスト(1行につきuser=password形式)に対して認証します。3つの組み込みスキームがサポートされています。Session(クライアントがまずHTTP GETを実行してセッションIDを受け取り、次にIDをパラメータとして渡してWebSocketを開く)、URL(ユーザー名とパスワードがWebSocketハンドシェイクのクエリ文字列で送信される)、Basic(HTTP Basic Access Authentication、VCLクライアント/サーバーとHTTPリクエストにのみ使用)。OnAuthenticationイベントで独自の認証チェックを追加できます。OnUnknownAuthenticationはBearer/JWTなどの非標準スキームを処理します。CustomHeadersを使用して認証エラー時に返す追加のHTTPヘッダーを追加できます。

使用例


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

プロパティに戻る