TsgcHTTPServer › 속성 › Authentication

Authentication 속성

들어오는 HTTP 연결에 대한 사용자/비밀번호 인증을 활성화하고 구성합니다.

구문

property Authentication: TsgcWSAuthenticationServer_Options read FAuthentication write SetAuthentication;

기본값

Enabled=False

설명

Authentication.Enabled가 True이면, 서버는 Basic 방식(HTTP 기본 액세스 인증)을 사용하여 들어오는 모든 연결을 AuthUsers 목록(줄마다 user=password 형식)에 대해 인증합니다. TsgcWebSocketHTTPServer에 문서화된 Session 및 URL 방식은 WebSocket 핸드셰이크에 자격 증명을 첨부하는 방식이며, 이 구성 요소는 연결을 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;

속성으로 돌아가기