mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 19:45:53 +00:00
Change the security model for RPC admin access.
This commit is contained in:
@@ -32,9 +32,6 @@ RPCServer::RPCServer(boost::asio::io_service& io_service , NetworkOPs* nopNetwor
|
||||
void RPCServer::connected()
|
||||
{
|
||||
//std::cerr << "RPC request" << std::endl;
|
||||
if (mSocket.remote_endpoint().address().to_string()=="127.0.0.1") mRole = RPCHandler::ADMIN;
|
||||
else mRole = RPCHandler::GUEST;
|
||||
|
||||
boost::asio::async_read_until(mSocket, mLineBuffer, "\r\n",
|
||||
boost::bind(&RPCServer::handle_read_line, shared_from_this(), boost::asio::placeholders::error));
|
||||
}
|
||||
@@ -114,16 +111,17 @@ std::string RPCServer::handleRequest(const std::string& requestStr)
|
||||
Json::Value id;
|
||||
|
||||
// Parse request
|
||||
Json::Value valRequest;
|
||||
Json::Reader reader;
|
||||
if (!reader.parse(requestStr, valRequest) || valRequest.isNull() || !valRequest.isObject())
|
||||
Json::Value jvRequest;
|
||||
Json::Reader reader;
|
||||
|
||||
if (!reader.parse(requestStr, jvRequest) || jvRequest.isNull() || !jvRequest.isObject())
|
||||
return(HTTPReply(400, "unable to parse request"));
|
||||
|
||||
// Parse id now so errors from here on will have the id
|
||||
id = valRequest["id"];
|
||||
id = jvRequest["id"];
|
||||
|
||||
// Parse method
|
||||
Json::Value valMethod = valRequest["method"];
|
||||
Json::Value valMethod = jvRequest["method"];
|
||||
if (valMethod.isNull())
|
||||
return(HTTPReply(400, "null method"));
|
||||
if (!valMethod.isString())
|
||||
@@ -131,11 +129,24 @@ std::string RPCServer::handleRequest(const std::string& requestStr)
|
||||
std::string strMethod = valMethod.asString();
|
||||
|
||||
// Parse params
|
||||
Json::Value valParams = valRequest["params"];
|
||||
Json::Value valParams = jvRequest["params"];
|
||||
|
||||
if (valParams.isNull())
|
||||
{
|
||||
valParams = Json::Value(Json::arrayValue);
|
||||
}
|
||||
else if (!valParams.isArray())
|
||||
return(HTTPReply(400, "params unparseable"));
|
||||
{
|
||||
return HTTPReply(400, "params unparseable");
|
||||
}
|
||||
|
||||
mRole = iAdminGet(jvRequest, mSocket.remote_endpoint().address().to_string());
|
||||
|
||||
if (RPCHandler::FORBID == mRole)
|
||||
{
|
||||
// XXX This needs rate limiting to prevent brute forcing password.
|
||||
return HTTPReply(403, "Forbidden");
|
||||
}
|
||||
|
||||
RPCHandler mRPCHandler(mNetOps);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user