TsgcWebSocketProxyServer › 이벤트 › 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 매개변수는 클라이언트가 제공한 자격 증명을 전달합니다. 연결을 수락하려면(프록시가 그 대신 업스트림 TCP 세션을 열도록) Authenticated를 True로, 거부하려면 False로 설정하십시오. 여기서 자격 증명이 검증되지 않으면 내장 AuthUsers 목록이 대체로 사용됩니다. 구성 요소가 인식하지 못하는 사용자 지정 방식(예: JWT Bearer 토큰)에는 대신 OnUnknownAuthentication을 사용하십시오.
procedure OnAuthentication(Connection: TsgcWSConnection; aUser, aPassword: string;
var Authenticated: Boolean);
begin
if ((aUser = 'user') and (aPassword = 'secret')) then
Authenticated := True
else
Authenticated := False;
end;