TsgcWSPServer_sgc › Properties › RPCAuthentication
可选的 RPC 方法及其执行所需匹配用户的允许列表。
property RPCAuthentication: TsgcWSAuthentication_Methods read FRPCAuthentication write SetRPCAuthentication;
—
当 Enabled 为 True 时,每个传入的 RPC 调用首先根据 Methods 列表进行检查。每个条目要么是裸方法名称(允许任何已认证用户),要么是 method=user 对(仅允许该已认证用户)。与任何条目都不匹配的方法会触发 OnRPCAuthentication 事件,处理程序可以在运行时决定;如果事件未分配或处理程序返回 False,服务器将回复 JSON-RPC"Method not found"错误。当 Enabled 为 False 时,接受每个方法。
oProtocol.RPCAuthentication.Enabled := True;
oProtocol.RPCAuthentication.Methods.Add('ping');
oProtocol.RPCAuthentication.Methods.Add('admin=root');