Add admin password check (#847)

Fixes #846
This commit is contained in:
Sergey Kuznetsov
2023-10-03 17:22:37 +01:00
committed by GitHub
parent e2cc56d25a
commit 0818b6ce5b
22 changed files with 478 additions and 117 deletions

View File

@@ -53,7 +53,7 @@ make_WsContext(
return Error{{ClioError::rpcINVALID_API_VERSION, apiVersion.error()}};
string const command = commandValue.as_string().c_str();
return web::Context(yc, command, *apiVersion, request, session, tagFactory, range, clientIp);
return web::Context(yc, command, *apiVersion, request, session, tagFactory, range, clientIp, session->isAdmin());
}
Expected<web::Context, Status>
@@ -63,7 +63,8 @@ make_HttpContext(
TagDecoratorFactory const& tagFactory,
data::LedgerRange const& range,
string const& clientIp,
std::reference_wrapper<APIVersionParser const> apiVersionParser)
std::reference_wrapper<APIVersionParser const> apiVersionParser,
bool const isAdmin)
{
if (!request.contains("method"))
return Error{{ClioError::rpcCOMMAND_IS_MISSING}};
@@ -91,7 +92,8 @@ make_HttpContext(
if (!apiVersion)
return Error{{ClioError::rpcINVALID_API_VERSION, apiVersion.error()}};
return web::Context(yc, command, *apiVersion, array.at(0).as_object(), nullptr, tagFactory, range, clientIp);
return web::Context(
yc, command, *apiVersion, array.at(0).as_object(), nullptr, tagFactory, range, clientIp, isAdmin);
}
} // namespace rpc