TsgcWSPServer_DatasetEvents › OnRPCAuthentication

OnRPCAuthentication Event

Fires when an RPC method is not on the allow-list, letting the handler authorise it.

Syntax

property OnRPCAuthentication: TsgcWSRPCAuthenticationEvent;
// TsgcWSRPCAuthenticationEvent = procedure(Connection: TsgcWSConnection; const Method, User, Password: string; var Authenticated: Boolean) of object

Default Value

Remarks

Only fires when RPCAuthentication.Enabled is True and the method name does not appear in RPCAuthentication.Methods either bare or as method=user. The handler receives the requested Method plus the User and Password presented on the WebSocket handshake; set Authenticated to True to dispatch OnRPC, or leave it False to have the server answer with a JSON-RPC "Method not found" error.

Example

procedure TForm1.oProtocolRPCAuthentication(Connection: TsgcWSConnection;
  const Method, User, Password: string; var Authenticated: Boolean);
begin
  Authenticated := (User = 'admin') and (Password = 'secret');
end;

Back to Events