TsgcWebSocketHTTPServer › 이벤트 › OnAuthentication
인증이 활성화되어 애플리케이션이 사용자와 비밀번호를 확인하고 연결을 수락하거나 거부할 수 있을 때 발생합니다.
property OnAuthentication: TsgcWSAuthenticationEvent;
// TsgcWSAuthenticationEvent = procedure(Connection: TsgcWSConnection; aUser, aPassword: String; var Authenticated: Boolean) of object
—
OnAuthentication은 Authentication.Enabled가 True이고 인증 방법이 내장 스키마(Basic, Session, URL) 중 하나인 경우, 서버가 클라이언트로부터 인증 요청을 받을 때마다 발생합니다. aUser 및 aPassword 매개변수는 클라이언트가 제공한 자격 증명을 전달합니다. 연결을 수락하려면 Authenticated를 True로, 거부하려면 False로 설정하십시오. 여기서 자격 증명이 검증되지 않으면 내장 AuthUsers 목록이 폴백으로 사용됩니다. 구성 요소가 인식하지 못하는 사용자 정의 스키마(예: JWT Bearer 토큰)의 경우 대신 OnUnknownAuthentication을 사용하십시오. 이 이벤트는 WebSocket 업그레이드와 일반 HTTP 요청 모두에 적용됩니다.
procedure OnAuthentication(Connection: TsgcWSConnection; aUser, aPassword: string;
var Authenticated: Boolean);
begin
if ((aUser = 'user') and (aPassword = 'secret')) then
Authenticated := True
else
Authenticated := False;
end;