TsgcHTTPServer › プロパティ › Authentication
受信する HTTP 接続のユーザー/パスワード認証を有効にして設定します。
property Authentication: TsgcWSAuthenticationServer_Options read FAuthentication write SetAuthentication;
Enabled=False
Authentication.EnabledがTrueの場合、サーバーはBasicスキーム(HTTP Basic Access Authentication)を使用して、受信するすべての接続をAuthUsersリスト(1行ごとにuser=password形式)に対して認証します。TsgcWebSocketHTTPServerで説明されているSessionおよびURLスキームは、WebSocketハンドシェイクに資格情報を付加するものであり、このコンポーネントは接続をアップグレードすることが決してないため、TsgcHTTPServerには効果がありません。OnAuthenticationイベントを使用すると、独自の資格情報チェックを組み込むことができます。OnUnknownAuthenticationはBearer/JWT/OAuth2/WebAuthnなどの非標準スキームを処理します。CustomHeadersを使用すると、認証エラー時に返される追加のHTTPヘッダーを設定できます。
oServer := TsgcHTTPServer.Create(nil);
oServer.Authentication.Enabled := true;
oServer.Authentication.Basic.Enabled := true;
oServer.Authentication.AuthUsers.Add('user=secret');
oServer.Active := true;