Klient TsgcWebSocket obsługuje 4 typy uwierzytelniania:
Jest to prosta metoda autoryzacji, w której nazwa użytkownika i hasło są kodowane i przekazywane jako nagłówek HTTP. Wystarczy ustawić pola User i Password oraz włączyć wyłącznie typ autoryzacji Basic, aby skorzystać z tej metody.
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;
Umożliwia autoryzację przy użyciu JWT. Wymaga wcześniejszego uzyskania tokenu za pomocą narzędzia zewnętrznego (na przykład połączenia HTTP, OAuth2 itp.).
Jeśli dołączony jest komponent OAuth2, token można uzyskać automatycznie. Więcej informacji na temat OAuth2.
Należy ustawić token AuthToken i włączyć uwierzytelnianie tokenem.
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;
Najpierw klient łączy się z serwerem przy użyciu połączenia HTTP, żądając nowej sesji. W przypadku powodzenia serwer zwraca SessionId, a klient wysyła ten SessionId w nagłówku HTTP GET podczas uzgadniania WebSocket.
Wymaga ustawienia nazwy użytkownika i hasła oraz włączenia uwierzytelniania sesji.
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;
Ta metoda uwierzytelniania przekazuje nazwę użytkownika i hasło w nagłówku HTTP GET podczas uzgadniania WebSocket.
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;