TsgcWebSocket 클라이언트는 4가지 유형의 인증을 지원합니다:
이것은 사용자와 비밀번호가 인코딩되어 HTTP Header로 전달되는 간단한 권한 부여 방법입니다. User와 Password를 설정하고 Basic Authorization 유형만 활성화하여 이 방법을 사용하십시오.
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;
먼저 클라이언트는 새 Session을 요청하는 HTTP 연결을 사용하여 서버에 연결합니다. 성공하면 서버는 SessionId를 반환하고 클라이언트는 WebSocket HandShake의 GET HTTP Header에 이 SessionId를 보냅니다.
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 HandShake의 GET HTTP Header에 사용자 이름과 비밀번호를 전달합니다.
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;