TsgcWebSocketServer_HTTPAPI › 속성 › Authentication
들어오는 WebSocket 및 HTTP 요청에 대한 사용자/비밀번호 인증을 활성화하고 구성합니다.
property Authentication: TsgcWSAuthenticationServer_Options read FAuthentication write SetAuthentication;
Enabled=False
Authentication.Enabled가 True이면 서버는 들어오는 모든 연결을 AuthUsers 목록(줄당 user=password 형식)에 대해 인증합니다. 세 가지 내장 방식이 지원됩니다: Session(클라이언트가 먼저 HTTP GET을 수행하여 세션 id를 받은 다음 id를 매개변수로 전달하여 WebSocket을 엶), URL(WebSocket HandShake의 쿼리 문자열에 username과 password가 전송됨), Basic(HTTP Basic Access Authentication — VCL 클라이언트/서버 및 HTTP 요청에서만 사용됨). OnAuthentication 이벤트를 사용하면 자체 자격 증명 검사를 연결할 수 있습니다. OnUnknownAuthentication은 Bearer/JWT와 같은 비표준 방식을 처리합니다. 인증 오류 시 반환되는 추가 HTTP 헤더를 추가하려면 CustomHeaders를 사용하십시오.
oServer := TsgcWebSocketServer_HTTPAPI.Create(nil);
oServer.Authentication.Enabled := true;
oServer.Authentication.Basic.Enabled := true;
oServer.Authentication.AuthUsers.Add('user=secret');
oServer.Active := true;