TsgcWSPServer_sgc › 이벤트 › OnRPCAuthentication
RPC 메서드가 allow-list에 없을 때 발생하여 핸들러가 이를 권한 부여할 수 있게 합니다.
property OnRPCAuthentication: TsgcWSRPCAuthenticationEvent;
// TsgcWSRPCAuthenticationEvent = procedure(Connection: TsgcWSConnection; const Method, User, Password: string; var Authenticated: Boolean) of object
—
RPCAuthentication.Enabled가 True이고 메서드 이름이 RPCAuthentication.Methods에 그대로 또는 method=user로 나타나지 않는 경우에만 발생합니다. 핸들러는 요청된 Method와 WebSocket 핸드셰이크에서 제시된 User 및 Password를 받습니다. OnRPC를 디스패치하려면 Authenticated를 True로 설정하고, 서버가 JSON-RPC "Method not found" 오류로 응답하게 하려면 False로 두십시오.
procedure TForm1.oProtocolRPCAuthentication(Connection: TsgcWSConnection;
const Method, User, Password: string; var Authenticated: Boolean);
begin
Authenticated := (User = 'admin') and (Password = 'secret');
end;