TsgcWebSocket クライアントは 4 種類の認証をサポートしています。
これは、ユーザーとパスワードがエンコードされ、HTTPヘッダーとして渡される単純な認可方法です。UserとPasswordを設定し、Basic認可タイプのみを有効にして、この方法を使用してください。
oClient := TsgcWebSocketClient.Create(nil); oClient.Authentication.Enabled := true; oClient.Authentication.Basic.Enabled := true; oClient.Authentication.User := 'your user'; oClient.Authentication.Password := 'your password'; oClient.Authentication.Token.Enabled := false; oClient.Authentication.URL.Enabled := false; oClient.Authentication.Session.Enabled := false; oClient.Active := True;
JWTを使用した認証が可能です。外部ツール(例: HTTP接続、OAuth2など)を使用してトークンを取得する必要があります。
OAuth2コンポーネントをアタッチすると、このトークンを自動的に取得できます。詳しくはOAuth2をご覧ください。
AuthTokenを設定し、Token Authenticationを有効にする必要があります。
oClient := TsgcWebSocketClient.Create(nil); oClient.Authentication.Enabled := true; oClient.Authentication.Token.Enabled := true; oClient.Authentication.Token.AuthToken := 'your token'; oClient.Authentication.Basic.Enabled := false; oClient.Authentication.URL.Enabled := false; oClient.Authentication.Session.Enabled := false; oClient.Active := True;
まずクライアントは HTTP 接続を使用して新しいセッションをリクエストするサーバーに接続します。成功した場合、サーバーは SessionId を返し、クライアントはこの SessionId を WebSocket ハンドシェイクの GET HTTP ヘッダーで送信します。
UserNameとPasswordの設定、およびSession Authenticationの有効化が必要です。
oClient := TsgcWebSocketClient.Create(nil); oClient.Authentication.Enabled := true; oClient.Authentication.Session.Enabled := true; oClient.Authentication.User := 'your user'; oClient.Authentication.Password := 'your password'; oClient.Authentication.Basic.Enabled := false; oClient.Authentication.URL.Enabled := false; oClient.Authentication.Token.Enabled := false; oClient.Active := True;
この認証方法は、WebSocketハンドシェイクのGET HTTPヘッダーでユーザー名とパスワードを渡します。
oClient := TsgcWebSocketClient.Create(nil); oClient.Authentication.Enabled := true; oClient.Authentication.URL.Enabled := true; oClient.Authentication.User := 'your user'; oClient.Authentication.Password := 'your password'; oClient.Authentication.Basic.Enabled := false; oClient.Authentication.Session.Enabled := false; oClient.Authentication.Token.Enabled := false; oClient.Active := True;