summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-03-25 23:07:27 +0300
committerEd Tanous <ed@tanous.net>2022-04-06 00:20:56 +0300
commit45ca1b868e47978a4d2e8ebb680cb384e804c97e (patch)
tree985a905fd8ac9bff693933ff98e3f4206f6aee4b /redfish-core
parente7b1b62b39ba31ba368c42cb6f4fa7af43c65961 (diff)
downloadbmcweb-45ca1b868e47978a4d2e8ebb680cb384e804c97e.tar.xz
Add setUpRedfishRoute to all nodes in redfish
For better or worse, the series ahead of this is making use of setUpRedfishRoute to do the common "redfish specified" things that need to be done for a connection, like header checking, filtering, and other things. In the current model, where BMCWEB_ROUTE is a common function for all HTTP routes, this means we need to propagate this injection call into the whole tree ahead of the requests being handled. In a perfect world, we would invent something like a REDFISH_ROUTE macro, but because macros are discouraged, the routes take a variadic template of parameters, and each call to the route has a .privileges() call in the middle, there's no good way to effect this change in a less costly manner. This was messaged both in the prior reviews, and on discord sourcing improvements on this pattern, to which none arose. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: Id29cc799e214edad41e48fc7ce6eed0521f90ecb
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/lib/account_service.hpp75
-rw-r--r--redfish-core/lib/bios.hpp21
-rw-r--r--redfish-core/lib/cable.hpp19
-rw-r--r--redfish-core/lib/certificate_service.hpp145
-rw-r--r--redfish-core/lib/chassis.hpp54
-rw-r--r--redfish-core/lib/ethernet.hpp88
-rw-r--r--redfish-core/lib/event_service.hpp78
-rw-r--r--redfish-core/lib/hypervisor_system.hpp80
-rw-r--r--redfish-core/lib/log_services.hpp843
-rw-r--r--redfish-core/lib/managers.hpp161
-rw-r--r--redfish-core/lib/memory.hpp19
-rw-r--r--redfish-core/lib/message_registries.hpp30
-rw-r--r--redfish-core/lib/metric_report.hpp20
-rw-r--r--redfish-core/lib/metric_report_definition.hpp42
-rw-r--r--redfish-core/lib/network_protocol.hpp20
-rw-r--r--redfish-core/lib/pcie.hpp343
-rw-r--r--redfish-core/lib/power.hpp23
-rw-r--r--redfish-core/lib/processor.hpp55
-rw-r--r--redfish-core/lib/redfish_sessions.hpp64
-rw-r--r--redfish-core/lib/roles.hpp19
-rw-r--r--redfish-core/lib/sensors.hpp106
-rw-r--r--redfish-core/lib/storage.hpp33
-rw-r--r--redfish-core/lib/systems.hpp37
-rw-r--r--redfish-core/lib/task.hpp37
-rw-r--r--redfish-core/lib/telemetry_service.hpp10
-rw-r--r--redfish-core/lib/thermal.hpp23
-rw-r--r--redfish-core/lib/trigger.hpp29
-rw-r--r--redfish-core/lib/update_service.hpp66
-rw-r--r--redfish-core/lib/virtual_media.hpp41
29 files changed, 1637 insertions, 944 deletions
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index 6e7cf288be..435d8906b1 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -20,6 +20,7 @@
#include <error_messages.hpp>
#include <openbmc_dbus_rest.hpp>
#include <persistent_data.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <sdbusplus/asio/property.hpp>
#include <utils/json_utils.hpp>
@@ -1261,11 +1262,14 @@ inline void requestAccountServiceRoutes(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/AccountService/")
.privileges(redfish::privileges::getAccountService)
- .methods(
- boost::beast::http::verb::get)([](const crow::Request& req,
- const std::shared_ptr<
- bmcweb::AsyncResp>& asyncResp)
- -> void {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) -> void {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
const persistent_data::AuthConfigMethods& authMethodsConfig =
persistent_data::SessionStore::getInstance()
.getAuthMethodsConfig();
@@ -1378,8 +1382,13 @@ inline void requestAccountServiceRoutes(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/AccountService/")
.privileges(redfish::privileges::patchAccountService)
.methods(boost::beast::http::verb::patch)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) -> void {
+ [&app](
+ const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) -> void {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::optional<uint32_t> unlockTimeout;
std::optional<uint16_t> lockoutThreshold;
std::optional<uint8_t> minPasswordLength;
@@ -1495,8 +1504,13 @@ inline void requestAccountServiceRoutes(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/AccountService/Accounts/")
.privileges(redfish::privileges::getManagerAccountCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) -> void {
+ [&app](
+ const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) -> void {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue = {
{"@odata.id", "/redfish/v1/AccountService/Accounts"},
{"@odata.type", "#ManagerAccountCollection."
@@ -1569,10 +1583,15 @@ inline void requestAccountServiceRoutes(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/AccountService/Accounts/")
.privileges(redfish::privileges::postManagerAccountCollection)
- .methods(boost::beast::http::verb::post)([](const crow::Request& req,
- const std::shared_ptr<
- bmcweb::AsyncResp>&
- asyncResp) -> void {
+ .methods(
+ boost::beast::http::verb::post)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) -> void {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::string username;
std::string password;
std::optional<std::string> roleId("User");
@@ -1689,9 +1708,13 @@ inline void requestAccountServiceRoutes(App& app)
.privileges(redfish::privileges::getManagerAccount)
.methods(
boost::beast::http::verb::
- get)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& accountName) -> void {
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& accountName) -> void {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
if (req.session->username != accountName)
{
// At this point we've determined that the user is trying to
@@ -1847,9 +1870,13 @@ inline void requestAccountServiceRoutes(App& app)
// yet
.privileges({{"ConfigureUsers"}, {"ConfigureSelf"}})
.methods(boost::beast::http::verb::patch)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& username) -> void {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& username) -> void {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::optional<std::string> newUserName;
std::optional<std::string> password;
std::optional<bool> enabled;
@@ -1924,9 +1951,13 @@ inline void requestAccountServiceRoutes(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/AccountService/Accounts/<str>/")
.privileges(redfish::privileges::deleteManagerAccount)
.methods(boost::beast::http::verb::delete_)(
- [](const crow::Request& /*req*/,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& username) -> void {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& username) -> void {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
sdbusplus::message::object_path tempObjPath(rootUserDbusPath);
tempObjPath /= username;
const std::string userPath(tempObjPath);
diff --git a/redfish-core/lib/bios.hpp b/redfish-core/lib/bios.hpp
index d8475aec1f..084c846891 100644
--- a/redfish-core/lib/bios.hpp
+++ b/redfish-core/lib/bios.hpp
@@ -1,17 +1,23 @@
#pragma once
#include <app.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <utils/fw_utils.hpp>
+
namespace redfish
{
/**
* BiosService class supports handle get method for bios.
*/
inline void
- handleBiosServiceGet(const crow::Request& /*req*/,
+ handleBiosServiceGet(crow::App& app, const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Systems/system/Bios";
asyncResp->res.jsonValue["@odata.type"] = "#Bios.v1_1_0.Bios";
asyncResp->res.jsonValue["Name"] = "BIOS Configuration";
@@ -24,11 +30,13 @@ inline void
fw_util::populateFirmwareInformation(asyncResp, fw_util::biosPurpose, "",
true);
}
+
inline void requestRoutesBiosService(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/")
.privileges(redfish::privileges::getBios)
- .methods(boost::beast::http::verb::get)(handleBiosServiceGet);
+ .methods(boost::beast::http::verb::get)(
+ std::bind_front(handleBiosServiceGet, std::ref(app)));
}
/**
@@ -39,9 +47,13 @@ inline void requestRoutesBiosService(App& app)
* Analyzes POST body message before sends Reset request data to D-Bus.
*/
inline void
- handleBiosResetPost(const crow::Request& /*req*/,
+ handleBiosResetPost(crow::App& app, const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec) {
if (ec)
@@ -59,7 +71,8 @@ inline void requestRoutesBiosReset(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Bios/Actions/Bios.ResetBios/")
.privileges(redfish::privileges::postBios)
- .methods(boost::beast::http::verb::post)(handleBiosResetPost);
+ .methods(boost::beast::http::verb::post)(
+ std::bind_front(handleBiosResetPost, std::ref(app)));
}
} // namespace redfish
diff --git a/redfish-core/lib/cable.hpp b/redfish-core/lib/cable.hpp
index 241baf4a1f..6ab87a8b31 100644
--- a/redfish-core/lib/cable.hpp
+++ b/redfish-core/lib/cable.hpp
@@ -1,5 +1,6 @@
#pragma once
#include <dbus_utility.hpp>
+#include <query.hpp>
#include <utils/json_utils.hpp>
namespace redfish
@@ -102,9 +103,13 @@ inline void requestRoutesCable(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Cables/<str>/")
.privileges(redfish::privileges::getCable)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& cableId) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& cableId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
BMCWEB_LOG_DEBUG << "Cable Id: " << cableId;
auto respHandler =
[asyncResp,
@@ -166,8 +171,12 @@ inline void requestRoutesCableCollection(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Cables/")
.privileges(redfish::privileges::getCableCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#CableCollection.CableCollection";
asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Cables";
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index 4882ec30f8..9bea9b98c4 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -4,6 +4,7 @@
#include <boost/convert.hpp>
#include <boost/convert/strtol.hpp>
#include <dbus_utility.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
namespace redfish
@@ -44,10 +45,14 @@ inline void requestRoutesCertificateService(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/CertificateService/")
.privileges(redfish::privileges::getCertificateService)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue = {
{"@odata.type",
"#CertificateService.v1_0_0.CertificateService"},
@@ -247,8 +252,13 @@ inline void requestRoutesCertificateActionGenerateCSR(App& app)
.privileges({{"ConfigureComponents"}})
.methods(
boost::beast::http::verb::
- post)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ post)([&app](
+ const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
static const int rsaKeyBitLength = 2048;
// Required parameters
@@ -674,8 +684,13 @@ inline void requestRoutesCertificateActionsReplaceCertificate(App& app)
.privileges(redfish::privileges::postCertificateService)
.methods(
boost::beast::http::verb::
- post)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ post)([&app](
+ const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::string certificate;
nlohmann::json certificateUri;
std::optional<std::string> certificateType = "PEM";
@@ -792,9 +807,13 @@ inline void requestRoutesHTTPSCertificate(App& app)
.privileges(redfish::privileges::getCertificate)
.methods(
boost::beast::http::verb::
- get)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& param) -> void {
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& param) -> void {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
if (param.empty())
{
messages::internalError(asyncResp->res);
@@ -824,10 +843,14 @@ inline void requestRoutesHTTPSCertificateCollection(App& app)
BMCWEB_ROUTE(app,
"/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates/")
.privileges(redfish::privileges::getCertificateCollection)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue = {
{"@odata.id",
"/redfish/v1/Managers/bmc/NetworkProtocol/HTTPS/Certificates"},
@@ -870,8 +893,13 @@ inline void requestRoutesHTTPSCertificateCollection(App& app)
.privileges(redfish::privileges::postCertificateCollection)
.methods(
boost::beast::http::verb::
- post)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ post)([&app](
+ const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
BMCWEB_LOG_DEBUG << "HTTPSCertificateCollection::doPost";
asyncResp->res.jsonValue = {{"Name", "HTTPS Certificate"},
@@ -972,10 +1000,14 @@ inline void requestRoutesCertificateLocations(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/CertificateService/CertificateLocations/")
.privileges(redfish::privileges::getCertificateLocations)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue = {
{"@odata.id",
"/redfish/v1/CertificateService/CertificateLocations"},
@@ -1011,10 +1043,14 @@ inline void requestRoutesLDAPCertificateCollection(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/AccountService/LDAP/Certificates/")
.privileges(redfish::privileges::getCertificateCollection)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue = {
{"@odata.id", "/redfish/v1/AccountService/LDAP/Certificates"},
{"@odata.type", "#CertificateCollection.CertificateCollection"},
@@ -1056,8 +1092,12 @@ inline void requestRoutesLDAPCertificateCollection(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/AccountService/LDAP/Certificates/")
.privileges(redfish::privileges::postCertificateCollection)
.methods(boost::beast::http::verb::post)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::string certFileBody =
getCertificateFromReqBody(asyncResp, req);
@@ -1113,9 +1153,13 @@ inline void requestRoutesLDAPCertificate(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/AccountService/LDAP/Certificates/<str>/")
.privileges(redfish::privileges::getCertificate)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string&) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string&) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
long id = getIDFromURL(req.url);
if (id < 0)
{
@@ -1143,10 +1187,14 @@ inline void requestRoutesTrustStoreCertificateCollection(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/Truststore/Certificates/")
.privileges(redfish::privileges::getCertificate)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue = {
{"@odata.id",
"/redfish/v1/Managers/bmc/Truststore/Certificates/"},
@@ -1189,8 +1237,13 @@ inline void requestRoutesTrustStoreCertificateCollection(App& app)
.privileges(redfish::privileges::postCertificateCollection)
.methods(
boost::beast::http::verb::
- post)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ post)([&app](
+ const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::string certFileBody =
getCertificateFromReqBody(asyncResp, req);
@@ -1244,9 +1297,13 @@ inline void requestRoutesTrustStoreCertificate(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/Truststore/Certificates/<str>/")
.privileges(redfish::privileges::getCertificate)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string&) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string&) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
long id = getIDFromURL(req.url);
if (id < 0)
{
@@ -1270,9 +1327,13 @@ inline void requestRoutesTrustStoreCertificate(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/Truststore/Certificates/<str>/")
.privileges(redfish::privileges::deleteCertificate)
.methods(boost::beast::http::verb::delete_)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& param) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& param) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
if (param.empty())
{
messages::internalError(asyncResp->res);
diff --git a/redfish-core/lib/chassis.hpp b/redfish-core/lib/chassis.hpp
index 45348dbca3..47b507005f 100644
--- a/redfish-core/lib/chassis.hpp
+++ b/redfish-core/lib/chassis.hpp
@@ -20,6 +20,7 @@
#include <app.hpp>
#include <dbus_utility.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <sdbusplus/asio/property.hpp>
#include <utils/collection.hpp>
@@ -141,8 +142,12 @@ inline void requestRoutesChassisCollection(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Chassis/")
.privileges(redfish::privileges::getChassisCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#ChassisCollection.ChassisCollection";
asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Chassis";
@@ -206,10 +211,14 @@ inline void requestRoutesChassis(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/")
.privileges(redfish::privileges::getChassis)
.methods(
- boost::beast::http::verb::get)([](const crow::Request&,
- const std::shared_ptr<
- bmcweb::AsyncResp>& asyncResp,
- const std::string& chassisId) {
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& chassisId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
const std::array<const char*, 2> interfaces = {
"xyz.openbmc_project.Inventory.Item.Board",
"xyz.openbmc_project.Inventory.Item.Chassis"};
@@ -438,9 +447,14 @@ inline void requestRoutesChassis(App& app)
.privileges(redfish::privileges::patchChassis)
.methods(
boost::beast::http::verb::
- patch)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& param) {
+ patch)([&app](
+ const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& param) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::optional<bool> locationIndicatorActive;
std::optional<std::string> indicatorLed;
@@ -636,9 +650,13 @@ inline void requestRoutesChassisResetAction(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Actions/Chassis.Reset/")
.privileges(redfish::privileges::postChassis)
.methods(boost::beast::http::verb::post)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string&) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string&) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
BMCWEB_LOG_DEBUG << "Post Chassis Reset.";
std::string resetType;
@@ -671,11 +689,13 @@ inline void requestRoutesChassisResetActionInfo(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/ResetActionInfo/")
.privileges(redfish::privileges::getActionInfo)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& chassisId)
-
- {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& chassisId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue = {
{"@odata.type", "#ActionInfo.v1_1_2.ActionInfo"},
{"@odata.id",
diff --git a/redfish-core/lib/ethernet.hpp b/redfish-core/lib/ethernet.hpp
index 85fa633330..bdc2a65152 100644
--- a/redfish-core/lib/ethernet.hpp
+++ b/redfish-core/lib/ethernet.hpp
@@ -20,6 +20,7 @@
#include <dbus_singleton.hpp>
#include <dbus_utility.hpp>
#include <error_messages.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <utils/json_utils.hpp>
@@ -1852,10 +1853,15 @@ inline void requestEthernetInterfacesRoutes(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/EthernetInterfaces/")
.privileges(redfish::privileges::getEthernetInterfaceCollection)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+
asyncResp->res.jsonValue["@odata.type"] =
"#EthernetInterfaceCollection.EthernetInterfaceCollection";
asyncResp->res.jsonValue["@odata.id"] =
@@ -1902,9 +1908,13 @@ inline void requestEthernetInterfacesRoutes(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/EthernetInterfaces/<str>/")
.privileges(redfish::privileges::getEthernetInterface)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& ifaceId) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& ifaceId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
getEthernetIfaceData(
ifaceId,
[asyncResp,
@@ -1939,9 +1949,13 @@ inline void requestEthernetInterfacesRoutes(App& app)
.privileges(redfish::privileges::patchEthernetInterface)
.methods(boost::beast::http::verb::patch)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& ifaceId) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& ifaceId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::optional<std::string> hostname;
std::optional<std::string> fqdn;
std::optional<std::string> macAddress;
@@ -2096,11 +2110,15 @@ inline void requestEthernetInterfacesRoutes(App& app)
BMCWEB_ROUTE(
app, "/redfish/v1/Managers/bmc/EthernetInterfaces/<str>/VLANs/<str>/")
.privileges(redfish::privileges::getVLanNetworkInterface)
-
.methods(boost::beast::http::verb::get)(
- [](const crow::Request& /* req */,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& parentIfaceId, const std::string& ifaceId) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& parentIfaceId,
+ const std::string& ifaceId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#VLanNetworkInterface.v1_1_0.VLanNetworkInterface";
asyncResp->res.jsonValue["Name"] = "VLAN Network Interface";
@@ -2142,9 +2160,14 @@ inline void requestEthernetInterfacesRoutes(App& app)
//.privileges(redfish::privileges::patchVLanNetworkInterface)
.privileges({{"ConfigureComponents"}})
.methods(boost::beast::http::verb::patch)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& parentIfaceId, const std::string& ifaceId) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& parentIfaceId,
+ const std::string& ifaceId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
if (!verifyNames(parentIfaceId, ifaceId))
{
messages::resourceNotFound(
@@ -2224,9 +2247,14 @@ inline void requestEthernetInterfacesRoutes(App& app)
//.privileges(redfish::privileges::deleteVLanNetworkInterface)
.privileges({{"ConfigureComponents"}})
.methods(boost::beast::http::verb::delete_)(
- [](const crow::Request& /* req */,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& parentIfaceId, const std::string& ifaceId) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& parentIfaceId,
+ const std::string& ifaceId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
if (!verifyNames(parentIfaceId, ifaceId))
{
messages::resourceNotFound(
@@ -2278,9 +2306,13 @@ inline void requestEthernetInterfacesRoutes(App& app)
.privileges(redfish::privileges::getVLanNetworkInterfaceCollection)
.methods(
boost::beast::http::verb::
- get)([](const crow::Request& /* req */,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& rootInterfaceName) {
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& rootInterfaceName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
// Get eth interface list, and call the below callback for JSON
// preparation
getEthernetIfaceList([asyncResp, rootInterfaceName](
@@ -2337,9 +2369,13 @@ inline void requestEthernetInterfacesRoutes(App& app)
//.privileges(redfish::privileges::postVLanNetworkInterfaceCollection)
.privileges({{"ConfigureComponents"}})
.methods(boost::beast::http::verb::post)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& rootInterfaceName) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& rootInterfaceName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
bool vlanEnable = false;
uint32_t vlanId = 0;
if (!json_util::readJsonPatch(req, asyncResp->res, "VLANId",
diff --git a/redfish-core/lib/event_service.hpp b/redfish-core/lib/event_service.hpp
index 134ef24a0c..04b46e0cdd 100644
--- a/redfish-core/lib/event_service.hpp
+++ b/redfish-core/lib/event_service.hpp
@@ -18,6 +18,7 @@
#include <app.hpp>
#include <boost/beast/http/fields.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <span>
@@ -46,10 +47,14 @@ inline void requestRoutesEventService(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/EventService/")
.privileges(redfish::privileges::getEventService)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue = {
{"@odata.type", "#EventService.v1_5_0.EventService"},
{"Id", "EventService"},
@@ -91,10 +96,12 @@ inline void requestRoutesEventService(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/EventService/")
.privileges(redfish::privileges::patchEventService)
.methods(boost::beast::http::verb::patch)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
-
- {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::optional<bool> serviceEnabled;
std::optional<uint32_t> retryAttemps;
std::optional<uint32_t> retryInterval;
@@ -159,8 +166,12 @@ inline void requestRoutesSubmitTestEvent(App& app)
app, "/redfish/v1/EventService/Actions/EventService.SubmitTestEvent/")
.privileges(redfish::privileges::postEventService)
.methods(boost::beast::http::verb::post)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
if (!EventServiceManager::getInstance().sendTestEventLog())
{
messages::serviceDisabled(asyncResp->res,
@@ -176,8 +187,12 @@ inline void requestRoutesEventDestinationCollection(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions/")
.privileges(redfish::privileges::getEventDestinationCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue = {
{"@odata.type",
"#EventDestinationCollection.EventDestinationCollection"},
@@ -204,8 +219,13 @@ inline void requestRoutesEventDestinationCollection(App& app)
.privileges(redfish::privileges::postEventDestinationCollection)
.methods(
boost::beast::http::verb::
- post)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ post)([&app](
+ const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
if (EventServiceManager::getInstance().getNumberOfSubscriptions() >=
maxNoOfSubscriptions)
{
@@ -501,9 +521,13 @@ inline void requestRoutesEventDestination(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions/<str>/")
.privileges(redfish::privileges::getEventDestination)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& param) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& param) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::shared_ptr<Subscription> subValue =
EventServiceManager::getInstance().getSubscription(param);
if (subValue == nullptr)
@@ -556,9 +580,13 @@ inline void requestRoutesEventDestination(App& app)
//.privileges(redfish::privileges::patchEventDestination)
.privileges({{"ConfigureManager"}})
.methods(boost::beast::http::verb::patch)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& param) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& param) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::shared_ptr<Subscription> subValue =
EventServiceManager::getInstance().getSubscription(param);
if (subValue == nullptr)
@@ -632,9 +660,13 @@ inline void requestRoutesEventDestination(App& app)
//.privileges(redfish::privileges::deleteEventDestination)
.privileges({{"ConfigureManager"}})
.methods(boost::beast::http::verb::delete_)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& param) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& param) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
if (!EventServiceManager::getInstance().isSubscriptionExist(
param))
{
diff --git a/redfish-core/lib/hypervisor_system.hpp b/redfish-core/lib/hypervisor_system.hpp
index ed83ff6ff9..e01b55f3e0 100644
--- a/redfish-core/lib/hypervisor_system.hpp
+++ b/redfish-core/lib/hypervisor_system.hpp
@@ -5,6 +5,7 @@
#include <dbus_singleton.hpp>
#include <dbus_utility.hpp>
#include <error_messages.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <sdbusplus/asio/property.hpp>
#include <utils/json_utils.hpp>
@@ -728,10 +729,14 @@ inline void requestRoutesHypervisorSystems(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Systems/hypervisor/")
.privileges(redfish::privileges::getComputerSystem)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
sdbusplus::asio::getProperty<std::string>(
*crow::connections::systemBus, "xyz.openbmc_project.Settings",
"/xyz/openbmc_project/network/hypervisor",
@@ -772,10 +777,14 @@ inline void requestRoutesHypervisorSystems(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Systems/hypervisor/EthernetInterfaces/")
.privileges(redfish::privileges::getEthernetInterfaceCollection)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
const std::array<const char*, 1> interfaces = {
"xyz.openbmc_project.Network.EthernetInterface"};
@@ -829,17 +838,21 @@ inline void requestRoutesHypervisorSystems(App& app)
BMCWEB_ROUTE(app,
"/redfish/v1/Systems/hypervisor/EthernetInterfaces/<str>/")
.privileges(redfish::privileges::getEthernetInterface)
- .methods(
- boost::beast::http::verb::get)([](const crow::Request&,
- const std::shared_ptr<
- bmcweb::AsyncResp>& asyncResp,
- const std::string& id) {
- getHypervisorIfaceData(
- id,
- [asyncResp, ifaceId{std::string(id)}](
- const bool& success, const EthernetInterfaceData& ethData,
- const boost::container::flat_set<IPv4AddressData>&
- ipv4Data) {
+ .methods(boost::beast::http::verb::get)(
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& id) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+ getHypervisorIfaceData(id, [asyncResp,
+ ifaceId{std::string(id)}](
+ const bool& success,
+ const EthernetInterfaceData&
+ ethData,
+ const boost::container::flat_set<
+ IPv4AddressData>& ipv4Data) {
if (!success)
{
messages::resourceNotFound(
@@ -855,16 +868,21 @@ inline void requestRoutesHypervisorSystems(App& app)
parseInterfaceData(asyncResp->res.jsonValue, ifaceId,
ethData, ipv4Data);
});
- });
+ });
BMCWEB_ROUTE(app,
"/redfish/v1/Systems/hypervisor/EthernetInterfaces/<str>/")
.privileges(redfish::privileges::patchEthernetInterface)
.methods(
boost::beast::http::verb::
- patch)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& ifaceId) {
+ patch)([&app](
+ const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& ifaceId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::optional<std::string> hostName;
std::optional<std::vector<nlohmann::json>> ipv4StaticAddresses;
std::optional<nlohmann::json> ipv4Addresses;
@@ -976,8 +994,12 @@ inline void requestRoutesHypervisorSystems(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Systems/hypervisor/ResetActionInfo/")
.privileges(redfish::privileges::getActionInfo)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
// Only return action info if hypervisor D-Bus object present
crow::connections::systemBus->async_method_call(
[asyncResp](
@@ -1035,8 +1057,12 @@ inline void requestRoutesHypervisorSystems(App& app)
"/redfish/v1/Systems/hypervisor/Actions/ComputerSystem.Reset/")
.privileges(redfish::privileges::postComputerSystem)
.methods(boost::beast::http::verb::post)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::optional<std::string> resetType;
if (!json_util::readJsonAction(req, asyncResp->res, "ResetType",
resetType))
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index e474f0ac44..b79fd03e9f 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -34,6 +34,7 @@
#include <boost/system/linux_error.hpp>
#include <dbus_utility.hpp>
#include <error_messages.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <charconv>
@@ -527,9 +528,14 @@ inline void
}
inline void
- getDumpEntryById(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ getDumpEntryById(crow::App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& entryID, const std::string& dumpType)
{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::string dumpPath;
if (dumpType == "BMC")
{
@@ -767,7 +773,6 @@ inline void
inline void createDump(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const crow::Request& req, const std::string& dumpType)
{
-
std::string dumpPath;
if (dumpType == "BMC")
{
@@ -934,89 +939,92 @@ inline void requestRoutesSystemLogServiceCollection(App& app)
*/
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/LogServices/")
.privileges(redfish::privileges::getLogServiceCollection)
- .methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
-
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
{
- // Collections don't include the static data added by SubRoute
- // because it has a duplicate entry for members
- asyncResp->res.jsonValue["@odata.type"] =
- "#LogServiceCollection.LogServiceCollection";
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Systems/system/LogServices";
- asyncResp->res.jsonValue["Name"] =
- "System Log Services Collection";
- asyncResp->res.jsonValue["Description"] =
- "Collection of LogServices for this Computer System";
- nlohmann::json& logServiceArray =
- asyncResp->res.jsonValue["Members"];
- logServiceArray = nlohmann::json::array();
- logServiceArray.push_back(
- {{"@odata.id",
- "/redfish/v1/Systems/system/LogServices/EventLog"}});
+ return;
+ }
+ // Collections don't include the static data added by SubRoute
+ // because it has a duplicate entry for members
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#LogServiceCollection.LogServiceCollection";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices";
+ asyncResp->res.jsonValue["Name"] = "System Log Services Collection";
+ asyncResp->res.jsonValue["Description"] =
+ "Collection of LogServices for this Computer System";
+ nlohmann::json& logServiceArray =
+ asyncResp->res.jsonValue["Members"];
+ logServiceArray = nlohmann::json::array();
+ logServiceArray.push_back(
+ {{"@odata.id",
+ "/redfish/v1/Systems/system/LogServices/EventLog"}});
#ifdef BMCWEB_ENABLE_REDFISH_DUMP_LOG
- logServiceArray.push_back(
- {{"@odata.id",
- "/redfish/v1/Systems/system/LogServices/Dump"}});
+ logServiceArray.push_back(
+ {{"@odata.id", "/redfish/v1/Systems/system/LogServices/Dump"}});
#endif
#ifdef BMCWEB_ENABLE_REDFISH_CPU_LOG
- logServiceArray.push_back(
- {{"@odata.id",
- "/redfish/v1/Systems/system/LogServices/Crashdump"}});
+ logServiceArray.push_back(
+ {{"@odata.id",
+ "/redfish/v1/Systems/system/LogServices/Crashdump"}});
#endif
#ifdef BMCWEB_ENABLE_REDFISH_HOST_LOGGER
- logServiceArray.push_back(
- {{"@odata.id",
- "/redfish/v1/Systems/system/LogServices/HostLogger"}});
+ logServiceArray.push_back(
+ {{"@odata.id",
+ "/redfish/v1/Systems/system/LogServices/HostLogger"}});
#endif
- asyncResp->res.jsonValue["Members@odata.count"] =
- logServiceArray.size();
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ logServiceArray.size();
- crow::connections::systemBus->async_method_call(
- [asyncResp](
- const boost::system::error_code ec,
- const dbus::utility::MapperGetSubTreePathsResponse&
- subtreePath) {
- if (ec)
- {
- BMCWEB_LOG_ERROR << ec;
- return;
- }
+ crow::connections::systemBus->async_method_call(
+ [asyncResp](const boost::system::error_code ec,
+ const dbus::utility::MapperGetSubTreePathsResponse&
+ subtreePath) {
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR << ec;
+ return;
+ }
- for (const auto& pathStr : subtreePath)
+ for (const auto& pathStr : subtreePath)
+ {
+ if (pathStr.find("PostCode") != std::string::npos)
{
- if (pathStr.find("PostCode") != std::string::npos)
- {
- nlohmann::json& logServiceArrayLocal =
- asyncResp->res.jsonValue["Members"];
- logServiceArrayLocal.push_back(
- {{"@odata.id",
- "/redfish/v1/Systems/system/LogServices/PostCodes"}});
- asyncResp->res
- .jsonValue["Members@odata.count"] =
- logServiceArrayLocal.size();
- return;
- }
+ nlohmann::json& logServiceArrayLocal =
+ asyncResp->res.jsonValue["Members"];
+ logServiceArrayLocal.push_back(
+ {{"@odata.id",
+ "/redfish/v1/Systems/system/LogServices/PostCodes"}});
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ logServiceArrayLocal.size();
+ return;
}
- },
- "xyz.openbmc_project.ObjectMapper",
- "/xyz/openbmc_project/object_mapper",
- "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", "/",
- 0, std::array<const char*, 1>{postCodeIface});
- });
+ }
+ },
+ "xyz.openbmc_project.ObjectMapper",
+ "/xyz/openbmc_project/object_mapper",
+ "xyz.openbmc_project.ObjectMapper", "GetSubTreePaths", "/", 0,
+ std::array<const char*, 1>{postCodeIface});
+ });
}
inline void requestRoutesEventLogService(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/LogServices/EventLog/")
.privileges(redfish::privileges::getLogService)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.id"] =
"/redfish/v1/Systems/system/LogServices/EventLog";
asyncResp->res.jsonValue["@odata.type"] =
@@ -1051,8 +1059,12 @@ inline void requestRoutesJournalEventLogClear(App& app)
"/redfish/v1/Systems/system/LogServices/EventLog/Actions/LogService.ClearLog/")
.privileges({{"ConfigureComponents"}})
.methods(boost::beast::http::verb::post)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
// Clear the EventLog by deleting the log files
std::vector<std::filesystem::path> redfishLogFiles;
if (getRedfishLogFiles(redfishLogFiles))
@@ -1184,10 +1196,14 @@ inline void requestRoutesJournalEventLogEntryCollection(App& app)
BMCWEB_ROUTE(app,
"/redfish/v1/Systems/system/LogServices/EventLog/Entries/")
.privileges(redfish::privileges::getLogEntryCollection)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
uint64_t skip = 0;
uint64_t top = maxEntriesPerPage; // Show max entries by default
if (!getSkipParam(asyncResp, req, skip))
@@ -1278,9 +1294,13 @@ inline void requestRoutesJournalEventLogEntry(App& app)
app, "/redfish/v1/Systems/system/LogServices/EventLog/Entries/<str>/")
.privileges(redfish::privileges::getLogEntry)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& param) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& param) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
const std::string& targetID = param;
// Go through the log files and check the unique ID for each
@@ -1339,10 +1359,14 @@ inline void requestRoutesDBusEventLogEntryCollection(App& app)
BMCWEB_ROUTE(app,
"/redfish/v1/Systems/system/LogServices/EventLog/Entries/")
.privileges(redfish::privileges::getLogEntryCollection)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
// Collections don't include the static data added by SubRoute
// because it has a duplicate entry for members
asyncResp->res.jsonValue["@odata.type"] =
@@ -1499,129 +1523,135 @@ inline void requestRoutesDBusEventLogEntry(App& app)
BMCWEB_ROUTE(
app, "/redfish/v1/Systems/system/LogServices/EventLog/Entries/<str>/")
.privileges(redfish::privileges::getLogEntry)
- .methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& param)
-
+ .methods(
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& param) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
{
- std::string entryID = param;
- dbus::utility::escapePathForDbus(entryID);
+ return;
+ }
+ std::string entryID = param;
+ dbus::utility::escapePathForDbus(entryID);
- // DBus implementation of EventLog/Entries
- // Make call to Logging Service to find all log entry objects
- crow::connections::systemBus->async_method_call(
- [asyncResp,
- entryID](const boost::system::error_code ec,
- const dbus::utility::DBusPropertiesMap& resp) {
- if (ec.value() == EBADR)
+ // DBus implementation of EventLog/Entries
+ // Make call to Logging Service to find all log entry objects
+ crow::connections::systemBus->async_method_call(
+ [asyncResp,
+ entryID](const boost::system::error_code ec,
+ const dbus::utility::DBusPropertiesMap& resp) {
+ if (ec.value() == EBADR)
+ {
+ messages::resourceNotFound(asyncResp->res,
+ "EventLogEntry", entryID);
+ return;
+ }
+ if (ec)
+ {
+ BMCWEB_LOG_ERROR
+ << "EventLogEntry (DBus) resp_handler got error "
+ << ec;
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ const uint32_t* id = nullptr;
+ const uint64_t* timestamp = nullptr;
+ const uint64_t* updateTimestamp = nullptr;
+ const std::string* severity = nullptr;
+ const std::string* message = nullptr;
+ const std::string* filePath = nullptr;
+ bool resolved = false;
+
+ for (const auto& propertyMap : resp)
+ {
+ if (propertyMap.first == "Id")
{
- messages::resourceNotFound(
- asyncResp->res, "EventLogEntry", entryID);
- return;
+ id = std::get_if<uint32_t>(&propertyMap.second);
}
- if (ec)
+ else if (propertyMap.first == "Timestamp")
{
- BMCWEB_LOG_ERROR
- << "EventLogEntry (DBus) resp_handler got error "
- << ec;
- messages::internalError(asyncResp->res);
- return;
+ timestamp =
+ std::get_if<uint64_t>(&propertyMap.second);
}
- const uint32_t* id = nullptr;
- const uint64_t* timestamp = nullptr;
- const uint64_t* updateTimestamp = nullptr;
- const std::string* severity = nullptr;
- const std::string* message = nullptr;
- const std::string* filePath = nullptr;
- bool resolved = false;
-
- for (const auto& propertyMap : resp)
+ else if (propertyMap.first == "UpdateTimestamp")
{
- if (propertyMap.first == "Id")
- {
- id = std::get_if<uint32_t>(&propertyMap.second);
- }
- else if (propertyMap.first == "Timestamp")
- {
- timestamp =
- std::get_if<uint64_t>(&propertyMap.second);
- }
- else if (propertyMap.first == "UpdateTimestamp")
- {
- updateTimestamp =
- std::get_if<uint64_t>(&propertyMap.second);
- }
- else if (propertyMap.first == "Severity")
- {
- severity = std::get_if<std::string>(
- &propertyMap.second);
- }
- else if (propertyMap.first == "Message")
- {
- message = std::get_if<std::string>(
- &propertyMap.second);
- }
- else if (propertyMap.first == "Resolved")
- {
- const bool* resolveptr =
- std::get_if<bool>(&propertyMap.second);
- if (resolveptr == nullptr)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- resolved = *resolveptr;
- }
- else if (propertyMap.first == "Path")
+ updateTimestamp =
+ std::get_if<uint64_t>(&propertyMap.second);
+ }
+ else if (propertyMap.first == "Severity")
+ {
+ severity =
+ std::get_if<std::string>(&propertyMap.second);
+ }
+ else if (propertyMap.first == "Message")
+ {
+ message =
+ std::get_if<std::string>(&propertyMap.second);
+ }
+ else if (propertyMap.first == "Resolved")
+ {
+ const bool* resolveptr =
+ std::get_if<bool>(&propertyMap.second);
+ if (resolveptr == nullptr)
{
- filePath = std::get_if<std::string>(
- &propertyMap.second);
+ messages::internalError(asyncResp->res);
+ return;
}
+ resolved = *resolveptr;
}
- if (id == nullptr || message == nullptr ||
- severity == nullptr || timestamp == nullptr ||
- updateTimestamp == nullptr)
+ else if (propertyMap.first == "Path")
{
- messages::internalError(asyncResp->res);
- return;
+ filePath =
+ std::get_if<std::string>(&propertyMap.second);
}
- asyncResp->res.jsonValue["@odata.type"] =
- "#LogEntry.v1_8_0.LogEntry";
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Systems/system/LogServices/EventLog/Entries/" +
+ }
+ if (id == nullptr || message == nullptr ||
+ severity == nullptr || timestamp == nullptr ||
+ updateTimestamp == nullptr)
+ {
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#LogEntry.v1_8_0.LogEntry";
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices/EventLog/Entries/" +
+ std::to_string(*id);
+ asyncResp->res.jsonValue["Name"] = "System Event Log Entry";
+ asyncResp->res.jsonValue["Id"] = std::to_string(*id);
+ asyncResp->res.jsonValue["Message"] = *message;
+ asyncResp->res.jsonValue["Resolved"] = resolved;
+ asyncResp->res.jsonValue["EntryType"] = "Event";
+ asyncResp->res.jsonValue["Severity"] =
+ translateSeverityDbusToRedfish(*severity);
+ asyncResp->res.jsonValue["Created"] =
+ crow::utility::getDateTimeUintMs(*timestamp);
+ asyncResp->res.jsonValue["Modified"] =
+ crow::utility::getDateTimeUintMs(*updateTimestamp);
+ if (filePath != nullptr)
+ {
+ asyncResp->res.jsonValue["AdditionalDataURI"] =
+ "/redfish/v1/Systems/system/LogServices/EventLog/attachment/" +
std::to_string(*id);
- asyncResp->res.jsonValue["Name"] =
- "System Event Log Entry";
- asyncResp->res.jsonValue["Id"] = std::to_string(*id);
- asyncResp->res.jsonValue["Message"] = *message;
- asyncResp->res.jsonValue["Resolved"] = resolved;
- asyncResp->res.jsonValue["EntryType"] = "Event";
- asyncResp->res.jsonValue["Severity"] =
- translateSeverityDbusToRedfish(*severity);
- asyncResp->res.jsonValue["Created"] =
- crow::utility::getDateTimeUintMs(*timestamp);
- asyncResp->res.jsonValue["Modified"] =
- crow::utility::getDateTimeUintMs(*updateTimestamp);
- if (filePath != nullptr)
- {
- asyncResp->res.jsonValue["AdditionalDataURI"] =
- "/redfish/v1/Systems/system/LogServices/EventLog/attachment/" +
- std::to_string(*id);
- }
- },
- "xyz.openbmc_project.Logging",
- "/xyz/openbmc_project/logging/entry/" + entryID,
- "org.freedesktop.DBus.Properties", "GetAll", "");
- });
+ }
+ },
+ "xyz.openbmc_project.Logging",
+ "/xyz/openbmc_project/logging/entry/" + entryID,
+ "org.freedesktop.DBus.Properties", "GetAll", "");
+ });
BMCWEB_ROUTE(
app, "/redfish/v1/Systems/system/LogServices/EventLog/Entries/<str>/")
.privileges(redfish::privileges::patchLogEntry)
.methods(boost::beast::http::verb::patch)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& entryId) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& entryId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::optional<bool> resolved;
if (!json_util::readJsonPatch(req, asyncResp->res, "Resolved",
@@ -1651,49 +1681,52 @@ inline void requestRoutesDBusEventLogEntry(App& app)
app, "/redfish/v1/Systems/system/LogServices/EventLog/Entries/<str>/")
.privileges(redfish::privileges::deleteLogEntry)
- .methods(boost::beast::http::verb::delete_)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& param)
-
+ .methods(boost::beast::http::verb::
+ delete_)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>&
+ asyncResp,
+ const std::string& param) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
{
- BMCWEB_LOG_DEBUG << "Do delete single event entries.";
+ return;
+ }
+ BMCWEB_LOG_DEBUG << "Do delete single event entries.";
- std::string entryID = param;
+ std::string entryID = param;
- dbus::utility::escapePathForDbus(entryID);
+ dbus::utility::escapePathForDbus(entryID);
- // Process response from Logging service.
- auto respHandler = [asyncResp, entryID](
- const boost::system::error_code ec) {
- BMCWEB_LOG_DEBUG
- << "EventLogEntry (DBus) doDelete callback: Done";
- if (ec)
+ // Process response from Logging service.
+ auto respHandler = [asyncResp,
+ entryID](const boost::system::error_code ec) {
+ BMCWEB_LOG_DEBUG
+ << "EventLogEntry (DBus) doDelete callback: Done";
+ if (ec)
+ {
+ if (ec.value() == EBADR)
{
- if (ec.value() == EBADR)
- {
- messages::resourceNotFound(asyncResp->res,
- "LogEntry", entryID);
- return;
- }
- // TODO Handle for specific error code
- BMCWEB_LOG_ERROR
- << "EventLogEntry (DBus) doDelete respHandler got error "
- << ec;
- asyncResp->res.result(
- boost::beast::http::status::internal_server_error);
+ messages::resourceNotFound(asyncResp->res, "LogEntry",
+ entryID);
return;
}
+ // TODO Handle for specific error code
+ BMCWEB_LOG_ERROR
+ << "EventLogEntry (DBus) doDelete respHandler got error "
+ << ec;
+ asyncResp->res.result(
+ boost::beast::http::status::internal_server_error);
+ return;
+ }
- asyncResp->res.result(boost::beast::http::status::ok);
- };
+ asyncResp->res.result(boost::beast::http::status::ok);
+ };
- // Make call to Logging service to request Delete Log
- crow::connections::systemBus->async_method_call(
- respHandler, "xyz.openbmc_project.Logging",
- "/xyz/openbmc_project/logging/entry/" + entryID,
- "xyz.openbmc_project.Object.Delete", "Delete");
- });
+ // Make call to Logging service to request Delete Log
+ crow::connections::systemBus->async_method_call(
+ respHandler, "xyz.openbmc_project.Logging",
+ "/xyz/openbmc_project/logging/entry/" + entryID,
+ "xyz.openbmc_project.Object.Delete", "Delete");
+ });
}
inline void requestRoutesDBusEventLogEntryDownload(App& app)
@@ -1703,11 +1736,13 @@ inline void requestRoutesDBusEventLogEntryDownload(App& app)
"/redfish/v1/Systems/system/LogServices/EventLog/Entries/<str>/attachment")
.privileges(redfish::privileges::getLogEntry)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& param)
-
- {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& param) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
if (!http_helpers::isOctetAccepted(
req.getHeaderValue("Accept")))
{
@@ -1875,10 +1910,14 @@ inline void requestRoutesSystemHostLogger(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/LogServices/HostLogger/")
.privileges(redfish::privileges::getLogService)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.id"] =
"/redfish/v1/Systems/system/LogServices/HostLogger";
asyncResp->res.jsonValue["@odata.type"] =
@@ -1897,10 +1936,14 @@ inline void requestRoutesSystemHostLoggerCollection(App& app)
BMCWEB_ROUTE(app,
"/redfish/v1/Systems/system/LogServices/HostLogger/Entries/")
.privileges(redfish::privileges::getLogEntry)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
uint64_t skip = 0;
uint64_t top = maxEntriesPerPage; // Show max 1000 entries by
// default, allow range 1 to
@@ -1975,9 +2018,13 @@ inline void requestRoutesSystemHostLoggerLogEntry(App& app)
app, "/redfish/v1/Systems/system/LogServices/HostLogger/Entries/<str>/")
.privileges(redfish::privileges::getLogEntry)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& param) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& param) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
const std::string& targetID = param;
uint64_t idInt = 0;
@@ -2034,8 +2081,12 @@ inline void requestRoutesBMCLogServiceCollection(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/LogServices/")
.privileges(redfish::privileges::getLogServiceCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
// Collections don't include the static data added by SubRoute
// because it has a duplicate entry for members
asyncResp->res.jsonValue["@odata.type"] =
@@ -2069,10 +2120,12 @@ inline void requestRoutesBMCJournalLogService(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/LogServices/Journal/")
.privileges(redfish::privileges::getLogService)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
-
- {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#LogService.v1_1_0.LogService";
asyncResp->res.jsonValue["@odata.id"] =
@@ -2162,10 +2215,14 @@ inline void requestRoutesBMCJournalLogEntryCollection(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/LogServices/Journal/Entries/")
.privileges(redfish::privileges::getLogEntryCollection)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
static constexpr const long maxEntriesPerPage = 1000;
uint64_t skip = 0;
uint64_t top = maxEntriesPerPage; // Show max entries by default
@@ -2252,9 +2309,13 @@ inline void requestRoutesBMCJournalLogEntry(App& app)
"/redfish/v1/Managers/bmc/LogServices/Journal/Entries/<str>/")
.privileges(redfish::privileges::getLogEntry)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& entryID) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& entryID) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
// Convert the unique ID back to a timestamp to find the entry
uint64_t ts = 0;
uint64_t index = 0;
@@ -2320,10 +2381,14 @@ inline void requestRoutesBMCDumpService(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/LogServices/Dump/")
.privileges(redfish::privileges::getLogService)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.id"] =
"/redfish/v1/Managers/bmc/LogServices/Dump";
asyncResp->res.jsonValue["@odata.type"] =
@@ -2361,8 +2426,12 @@ inline void requestRoutesBMCDumpEntryCollection(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/LogServices/Dump/Entries/")
.privileges(redfish::privileges::getLogEntryCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#LogEntryCollection.LogEntryCollection";
asyncResp->res.jsonValue["@odata.id"] =
@@ -2381,32 +2450,44 @@ inline void requestRoutesBMCDumpEntry(App& app)
"/redfish/v1/Managers/bmc/LogServices/Dump/Entries/<str>/")
.privileges(redfish::privileges::getLogEntry)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& param) {
- getDumpEntryById(asyncResp, param, "BMC");
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& param) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+
+ getDumpEntryById(app, req, asyncResp, param, "BMC");
});
BMCWEB_ROUTE(app,
"/redfish/v1/Managers/bmc/LogServices/Dump/Entries/<str>/")
.privileges(redfish::privileges::deleteLogEntry)
.methods(boost::beast::http::verb::delete_)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& param) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& param) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
deleteDumpEntry(asyncResp, param, "bmc");
});
}
inline void requestRoutesBMCDumpCreate(App& app)
{
-
BMCWEB_ROUTE(
app,
"/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.CollectDiagnosticData/")
.privileges(redfish::privileges::postLogService)
.methods(boost::beast::http::verb::post)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
createDump(asyncResp, req, "BMC");
});
}
@@ -2418,8 +2499,12 @@ inline void requestRoutesBMCDumpClear(App& app)
"/redfish/v1/Managers/bmc/LogServices/Dump/Actions/LogService.ClearLog/")
.privileges(redfish::privileges::postLogService)
.methods(boost::beast::http::verb::post)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
clearDump(asyncResp, "BMC");
});
}
@@ -2428,39 +2513,40 @@ inline void requestRoutesSystemDumpService(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/LogServices/Dump/")
.privileges(redfish::privileges::getLogService)
- .methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
-
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
{
- asyncResp->res.jsonValue["@odata.id"] =
- "/redfish/v1/Systems/system/LogServices/Dump";
- asyncResp->res.jsonValue["@odata.type"] =
- "#LogService.v1_2_0.LogService";
- asyncResp->res.jsonValue["Name"] = "Dump LogService";
- asyncResp->res.jsonValue["Description"] =
- "System Dump LogService";
- asyncResp->res.jsonValue["Id"] = "Dump";
- asyncResp->res.jsonValue["OverWritePolicy"] = "WrapsWhenFull";
+ return;
+ }
+ asyncResp->res.jsonValue["@odata.id"] =
+ "/redfish/v1/Systems/system/LogServices/Dump";
+ asyncResp->res.jsonValue["@odata.type"] =
+ "#LogService.v1_2_0.LogService";
+ asyncResp->res.jsonValue["Name"] = "Dump LogService";
+ asyncResp->res.jsonValue["Description"] = "System Dump LogService";
+ asyncResp->res.jsonValue["Id"] = "Dump";
+ asyncResp->res.jsonValue["OverWritePolicy"] = "WrapsWhenFull";
- std::pair<std::string, std::string> redfishDateTimeOffset =
- crow::utility::getDateTimeOffsetNow();
- asyncResp->res.jsonValue["DateTime"] =
- redfishDateTimeOffset.first;
- asyncResp->res.jsonValue["DateTimeLocalOffset"] =
- redfishDateTimeOffset.second;
+ std::pair<std::string, std::string> redfishDateTimeOffset =
+ crow::utility::getDateTimeOffsetNow();
+ asyncResp->res.jsonValue["DateTime"] = redfishDateTimeOffset.first;
+ asyncResp->res.jsonValue["DateTimeLocalOffset"] =
+ redfishDateTimeOffset.second;
- asyncResp->res.jsonValue["Entries"] = {
- {"@odata.id",
- "/redfish/v1/Systems/system/LogServices/Dump/Entries"}};
- asyncResp->res.jsonValue["Actions"] = {
- {"#LogService.ClearLog",
- {{"target",
- "/redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.ClearLog"}}},
- {"#LogService.CollectDiagnosticData",
- {{"target",
- "/redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.CollectDiagnosticData"}}}};
- });
+ asyncResp->res.jsonValue["Entries"] = {
+ {"@odata.id",
+ "/redfish/v1/Systems/system/LogServices/Dump/Entries"}};
+ asyncResp->res.jsonValue["Actions"] = {
+ {"#LogService.ClearLog",
+ {{"target",
+ "/redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.ClearLog"}}},
+ {"#LogService.CollectDiagnosticData",
+ {{"target",
+ "/redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.CollectDiagnosticData"}}}};
+ });
}
inline void requestRoutesSystemDumpEntryCollection(App& app)
@@ -2472,8 +2558,12 @@ inline void requestRoutesSystemDumpEntryCollection(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/LogServices/Dump/Entries/")
.privileges(redfish::privileges::getLogEntryCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#LogEntryCollection.LogEntryCollection";
asyncResp->res.jsonValue["@odata.id"] =
@@ -2493,19 +2583,23 @@ inline void requestRoutesSystemDumpEntry(App& app)
.privileges(redfish::privileges::getLogEntry)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& param) {
- getDumpEntryById(asyncResp, param, "System");
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& param) {
+ getDumpEntryById(app, req, asyncResp, param, "System");
});
BMCWEB_ROUTE(app,
"/redfish/v1/Systems/system/LogServices/Dump/Entries/<str>/")
.privileges(redfish::privileges::deleteLogEntry)
.methods(boost::beast::http::verb::delete_)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& param) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& param) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
deleteDumpEntry(asyncResp, param, "system");
});
}
@@ -2517,10 +2611,14 @@ inline void requestRoutesSystemDumpCreate(App& app)
"/redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.CollectDiagnosticData/")
.privileges(redfish::privileges::postLogService)
.methods(boost::beast::http::verb::post)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
-
- { createDump(asyncResp, req, "System"); });
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+ createDump(asyncResp, req, "System");
+ });
}
inline void requestRoutesSystemDumpClear(App& app)
@@ -2530,10 +2628,16 @@ inline void requestRoutesSystemDumpClear(App& app)
"/redfish/v1/Systems/system/LogServices/Dump/Actions/LogService.ClearLog/")
.privileges(redfish::privileges::postLogService)
.methods(boost::beast::http::verb::post)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
- { clearDump(asyncResp, "System"); });
+ {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+ clearDump(asyncResp, "System");
+ });
}
inline void requestRoutesCrashdumpService(App& app)
@@ -2547,10 +2651,14 @@ inline void requestRoutesCrashdumpService(App& app)
// This is incorrect, should be:
//.privileges(redfish::privileges::getLogService)
.privileges({{"ConfigureManager"}})
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
// Copy over the static data to include the entries added by
// SubRoute
asyncResp->res.jsonValue["@odata.id"] =
@@ -2591,8 +2699,12 @@ void inline requestRoutesCrashdumpClear(App& app)
//.privileges(redfish::privileges::postLogService)
.privileges({{"ConfigureComponents"}})
.methods(boost::beast::http::verb::post)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec,
const std::string&) {
@@ -2692,10 +2804,14 @@ inline void requestRoutesCrashdumpEntryCollection(App& app)
// This is incorrect, should be.
//.privileges(redfish::privileges::postLogEntryCollection)
.privileges({{"ConfigureComponents"}})
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
crow::connections::systemBus->async_method_call(
[asyncResp](const boost::system::error_code ec,
const std::vector<std::string>& resp) {
@@ -2754,9 +2870,13 @@ inline void requestRoutesCrashdumpEntry(App& app)
// .privileges(redfish::privileges::getLogEntry)
.privileges({{"ConfigureComponents"}})
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& param) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& param) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
const std::string& logID = param;
logCrashdumpEntry(asyncResp, logID, asyncResp->res.jsonValue);
});
@@ -2771,9 +2891,13 @@ inline void requestRoutesCrashdumpFile(App& app)
"/redfish/v1/Systems/system/LogServices/Crashdump/Entries/<str>/<str>/")
.privileges(redfish::privileges::getLogEntry)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& logID, const std::string& fileName) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& logID, const std::string& fileName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
auto getStoredLogCallback =
[asyncResp, logID, fileName,
url(boost::urls::url(req.urlView))](
@@ -2867,8 +2991,13 @@ inline void requestRoutesCrashdumpCollect(App& app)
.privileges({{"ConfigureComponents"}})
.methods(
boost::beast::http::verb::
- post)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ post)([&app](
+ const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::string diagnosticDataType;
std::string oemDiagnosticDataType;
if (!redfish::json_util::readJsonAction(
@@ -2990,8 +3119,12 @@ inline void requestRoutesDBusLogServiceActionsClear(App& app)
"/redfish/v1/Systems/system/LogServices/EventLog/Actions/LogService.ClearLog/")
.privileges(redfish::privileges::postLogService)
.methods(boost::beast::http::verb::post)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
BMCWEB_LOG_DEBUG << "Do delete all entries.";
// Process response from Logging service.
@@ -3029,10 +3162,14 @@ inline void requestRoutesPostCodesLogService(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/LogServices/PostCodes/")
.privileges(redfish::privileges::getLogService)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue = {
{"@odata.id",
"/redfish/v1/Systems/system/LogServices/PostCodes"},
@@ -3066,8 +3203,12 @@ inline void requestRoutesPostCodesClear(App& app)
//.privileges(redfish::privileges::postLogService)
.privileges({{"ConfigureComponents"}})
.methods(boost::beast::http::verb::post)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
BMCWEB_LOG_DEBUG << "Do delete all postcodes entries.";
// Make call to post-code service to request clear all
@@ -3335,8 +3476,12 @@ inline void requestRoutesPostCodesEntryCollection(App& app)
"/redfish/v1/Systems/system/LogServices/PostCodes/Entries/")
.privileges(redfish::privileges::getLogEntryCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#LogEntryCollection.LogEntryCollection";
asyncResp->res.jsonValue["@odata.id"] =
@@ -3408,9 +3553,13 @@ inline void requestRoutesPostCodesEntryAdditionalData(App& app)
"/redfish/v1/Systems/system/LogServices/PostCodes/Entries/<str>/attachment/")
.privileges(redfish::privileges::getLogEntry)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& postCodeID) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& postCodeID) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
if (!http_helpers::isOctetAccepted(
req.getHeaderValue("Accept")))
{
@@ -3488,9 +3637,13 @@ inline void requestRoutesPostCodesEntry(App& app)
app, "/redfish/v1/Systems/system/LogServices/PostCodes/Entries/<str>/")
.privileges(redfish::privileges::getLogEntry)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& targetID) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& targetID) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
uint16_t bootIndex = 0;
uint64_t codeIndex = 0;
if (!parsePostCode(targetID, codeIndex, bootIndex))
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index 96b0d5d205..aa4c694da9 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -22,6 +22,7 @@
#include <boost/algorithm/string/replace.hpp>
#include <boost/date_time.hpp>
#include <dbus_utility.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <utils/fw_utils.hpp>
#include <utils/systemd_utils.hpp>
@@ -112,8 +113,12 @@ inline void requestRoutesManagerResetAction(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/Actions/Manager.Reset/")
.privileges(redfish::privileges::postManager)
.methods(boost::beast::http::verb::post)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
BMCWEB_LOG_DEBUG << "Post Manager Reset.";
std::string resetType;
@@ -168,8 +173,12 @@ inline void requestRoutesManagerResetToDefaultsAction(App& app)
"/redfish/v1/Managers/bmc/Actions/Manager.ResetToDefaults/")
.privileges(redfish::privileges::postManager)
.methods(boost::beast::http::verb::post)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
BMCWEB_LOG_DEBUG << "Post ResetToDefaults.";
std::string resetType;
@@ -227,8 +236,12 @@ inline void requestRoutesManagerResetActionInfo(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/ResetActionInfo/")
.privileges(redfish::privileges::getActionInfo)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue = {
{"@odata.type", "#ActionInfo.v1_1_2.ActionInfo"},
{"@odata.id", "/redfish/v1/Managers/bmc/ResetActionInfo"},
@@ -1948,10 +1961,15 @@ inline void requestRoutesManager(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/")
.privileges(redfish::privileges::getManager)
- .methods(boost::beast::http::verb::get)([uuid](const crow::Request&,
- const std::shared_ptr<
- bmcweb::AsyncResp>&
- asyncResp) {
+ .methods(
+ boost::beast::http::verb::
+ get)([&app, uuid](
+ const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Managers/bmc";
asyncResp->res.jsonValue["@odata.type"] =
"#Manager.v1_11_0.Manager";
@@ -2197,83 +2215,88 @@ inline void requestRoutesManager(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/")
.privileges(redfish::privileges::patchManager)
- .methods(
- boost::beast::http::verb::
- patch)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
- std::optional<nlohmann::json> oem;
- std::optional<nlohmann::json> links;
- std::optional<std::string> datetime;
-
- if (!json_util::readJsonPatch(req, asyncResp->res, "Oem", oem,
- "DateTime", datetime, "Links", links))
- {
- return;
- }
+ .methods(boost::beast::http::verb::patch)(
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+ std::optional<nlohmann::json> oem;
+ std::optional<nlohmann::json> links;
+ std::optional<std::string> datetime;
- if (oem)
- {
- std::optional<nlohmann::json> openbmc;
- if (!redfish::json_util::readJson(*oem, asyncResp->res,
- "OpenBmc", openbmc))
+ if (!json_util::readJsonPatch(req, asyncResp->res, "Oem", oem,
+ "DateTime", datetime, "Links",
+ links))
{
- BMCWEB_LOG_ERROR
- << "Illegal Property "
- << oem->dump(2, ' ', true,
- nlohmann::json::error_handler_t::replace);
return;
}
- if (openbmc)
+
+ if (oem)
{
- std::optional<nlohmann::json> fan;
- if (!redfish::json_util::readJson(*openbmc, asyncResp->res,
- "Fan", fan))
+ std::optional<nlohmann::json> openbmc;
+ if (!redfish::json_util::readJson(*oem, asyncResp->res,
+ "OpenBmc", openbmc))
{
BMCWEB_LOG_ERROR
<< "Illegal Property "
- << openbmc->dump(
+ << oem->dump(
2, ' ', true,
nlohmann::json::error_handler_t::replace);
return;
}
- if (fan)
+ if (openbmc)
{
- auto pid =
- std::make_shared<SetPIDValues>(asyncResp, *fan);
- pid->run();
+ std::optional<nlohmann::json> fan;
+ if (!redfish::json_util::readJson(
+ *openbmc, asyncResp->res, "Fan", fan))
+ {
+ BMCWEB_LOG_ERROR
+ << "Illegal Property "
+ << openbmc->dump(2, ' ', true,
+ nlohmann::json::
+ error_handler_t::replace);
+ return;
+ }
+ if (fan)
+ {
+ auto pid =
+ std::make_shared<SetPIDValues>(asyncResp, *fan);
+ pid->run();
+ }
}
}
- }
- if (links)
- {
- std::optional<nlohmann::json> activeSoftwareImage;
- if (!redfish::json_util::readJson(*links, asyncResp->res,
- "ActiveSoftwareImage",
- activeSoftwareImage))
- {
- return;
- }
- if (activeSoftwareImage)
+ if (links)
{
- std::optional<std::string> odataId;
- if (!json_util::readJson(*activeSoftwareImage,
- asyncResp->res, "@odata.id",
- odataId))
+ std::optional<nlohmann::json> activeSoftwareImage;
+ if (!redfish::json_util::readJson(*links, asyncResp->res,
+ "ActiveSoftwareImage",
+ activeSoftwareImage))
{
return;
}
-
- if (odataId)
+ if (activeSoftwareImage)
{
- setActiveFirmwareImage(asyncResp, *odataId);
+ std::optional<std::string> odataId;
+ if (!json_util::readJson(*activeSoftwareImage,
+ asyncResp->res, "@odata.id",
+ odataId))
+ {
+ return;
+ }
+
+ if (odataId)
+ {
+ setActiveFirmwareImage(asyncResp, *odataId);
+ }
}
}
- }
- if (datetime)
- {
- setDateTime(asyncResp, std::move(*datetime));
- }
- });
+ if (datetime)
+ {
+ setDateTime(asyncResp, std::move(*datetime));
+ }
+ });
}
inline void requestRoutesManagerCollection(App& app)
@@ -2281,8 +2304,12 @@ inline void requestRoutesManagerCollection(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Managers/")
.privileges(redfish::privileges::getManagerCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
// Collections don't include the static data added by SubRoute
// because it has a duplicate entry for members
asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Managers";
diff --git a/redfish-core/lib/memory.hpp b/redfish-core/lib/memory.hpp
index 6d035142da..20bbfb283c 100644
--- a/redfish-core/lib/memory.hpp
+++ b/redfish-core/lib/memory.hpp
@@ -19,6 +19,7 @@
#include <app.hpp>
#include <dbus_utility.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <utils/collection.hpp>
#include <utils/hex_utils.hpp>
@@ -870,8 +871,12 @@ inline void requestRoutesMemoryCollection(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Memory/")
.privileges(redfish::privileges::getMemoryCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#MemoryCollection.MemoryCollection";
asyncResp->res.jsonValue["Name"] = "Memory Module Collection";
@@ -892,9 +897,13 @@ inline void requestRoutesMemory(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Memory/<str>/")
.privileges(redfish::privileges::getMemory)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& dimmId) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& dimmId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#Memory.v1_11_0.Memory";
asyncResp->res.jsonValue["@odata.id"] =
diff --git a/redfish-core/lib/message_registries.hpp b/redfish-core/lib/message_registries.hpp
index c030e5ae7a..fe4c592006 100644
--- a/redfish-core/lib/message_registries.hpp
+++ b/redfish-core/lib/message_registries.hpp
@@ -22,15 +22,20 @@
#include "registries/task_event_message_registry.hpp"
#include <app.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
namespace redfish
{
inline void handleMessageRegistryFileCollectionGet(
- const crow::Request& /*req*/,
+ crow::App& app, const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
// Collections don't include the static data added by SubRoute
// because it has a duplicate entry for members
@@ -55,15 +60,19 @@ inline void requestRoutesMessageRegistryFileCollection(App& app)
*/
BMCWEB_ROUTE(app, "/redfish/v1/Registries/")
.privileges(redfish::privileges::getMessageRegistryFileCollection)
- .methods(boost::beast::http::verb::get)(
- handleMessageRegistryFileCollectionGet);
+ .methods(boost::beast::http::verb::get)(std::bind_front(
+ handleMessageRegistryFileCollectionGet, std::ref(app)));
}
inline void handleMessageRoutesMessageRegistryFileGet(
- const crow::Request& /*req*/,
+ crow::App& app, const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& registry)
{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
const registries::Header* header = nullptr;
std::string dmtf = "DMTF ";
const char* url = nullptr;
@@ -120,16 +129,20 @@ inline void requestRoutesMessageRegistryFile(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Registries/<str>/")
.privileges(redfish::privileges::getMessageRegistryFile)
- .methods(boost::beast::http::verb::get)(
- handleMessageRoutesMessageRegistryFileGet);
+ .methods(boost::beast::http::verb::get)(std::bind_front(
+ handleMessageRoutesMessageRegistryFileGet, std::ref(app)));
}
inline void handleMessageRegistryGet(
- const crow::Request& /*req*/,
+ crow::App& app, const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& registry, const std::string& registryMatch)
{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
const registries::Header* header = nullptr;
std::vector<const registries::MessageEntry*> registryEntries;
if (registry == "Base")
@@ -223,6 +236,7 @@ inline void requestRoutesMessageRegistry(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Registries/<str>/<str>/")
.privileges(redfish::privileges::getMessageRegistryFile)
- .methods(boost::beast::http::verb::get)(handleMessageRegistryGet);
+ .methods(boost::beast::http::verb::get)(
+ std::bind_front(handleMessageRegistryGet, std::ref(app)));
}
} // namespace redfish
diff --git a/redfish-core/lib/metric_report.hpp b/redfish-core/lib/metric_report.hpp
index 2fb8d8225f..a47f6efcf4 100644
--- a/redfish-core/lib/metric_report.hpp
+++ b/redfish-core/lib/metric_report.hpp
@@ -5,6 +5,7 @@
#include <app.hpp>
#include <dbus_utility.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <sdbusplus/asio/property.hpp>
@@ -65,8 +66,13 @@ inline void requestRoutesMetricReportCollection(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/TelemetryService/MetricReports/")
.privileges(redfish::privileges::getMetricReportCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+
asyncResp->res.jsonValue["@odata.type"] =
"#MetricReportCollection.MetricReportCollection";
asyncResp->res.jsonValue["@odata.id"] =
@@ -85,9 +91,13 @@ inline void requestRoutesMetricReport(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/TelemetryService/MetricReports/<str>/")
.privileges(redfish::privileges::getMetricReport)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& id) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& id) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
const std::string reportPath = telemetry::getDbusReportPath(id);
crow::connections::systemBus->async_method_call(
[asyncResp, id,
diff --git a/redfish-core/lib/metric_report_definition.hpp b/redfish-core/lib/metric_report_definition.hpp
index e960af7f3e..d61afd96aa 100644
--- a/redfish-core/lib/metric_report_definition.hpp
+++ b/redfish-core/lib/metric_report_definition.hpp
@@ -7,6 +7,7 @@
#include <app.hpp>
#include <boost/container/flat_map.hpp>
#include <dbus_utility.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <tuple>
@@ -366,8 +367,13 @@ inline void requestRoutesMetricReportDefinitionCollection(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/TelemetryService/MetricReportDefinitions/")
.privileges(redfish::privileges::getMetricReportDefinitionCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+
asyncResp->res.jsonValue["@odata.type"] =
"#MetricReportDefinitionCollection."
"MetricReportDefinitionCollection";
@@ -386,8 +392,14 @@ inline void requestRoutesMetricReportDefinitionCollection(App& app)
.privileges(redfish::privileges::postMetricReportDefinitionCollection)
.methods(
boost::beast::http::verb::
- post)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ post)([&app](
+ const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+
telemetry::AddReportArgs args;
if (!telemetry::getUserParameters(asyncResp->res, req, args))
{
@@ -431,9 +443,14 @@ inline void requestRoutesMetricReportDefinition(App& app)
"/redfish/v1/TelemetryService/MetricReportDefinitions/<str>/")
.privileges(redfish::privileges::getMetricReportDefinition)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& id) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& id) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+
crow::connections::systemBus->async_method_call(
[asyncResp,
id](const boost::system::error_code ec,
@@ -464,11 +481,16 @@ inline void requestRoutesMetricReportDefinition(App& app)
"/redfish/v1/TelemetryService/MetricReportDefinitions/<str>/")
.privileges(redfish::privileges::deleteMetricReportDefinitionCollection)
.methods(boost::beast::http::verb::delete_)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& id)
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& id)
{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+
const std::string reportPath = telemetry::getDbusReportPath(id);
crow::connections::systemBus->async_method_call(
diff --git a/redfish-core/lib/network_protocol.hpp b/redfish-core/lib/network_protocol.hpp
index aac7f668a6..7e50b46776 100644
--- a/redfish-core/lib/network_protocol.hpp
+++ b/redfish-core/lib/network_protocol.hpp
@@ -21,6 +21,7 @@
#include <app.hpp>
#include <dbus_utility.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <sdbusplus/asio/property.hpp>
#include <utils/json_utils.hpp>
@@ -400,9 +401,14 @@ inline void requestRoutesNetworkProtocol(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/NetworkProtocol/")
.privileges(redfish::privileges::patchManagerNetworkProtocol)
.methods(
- boost::beast::http::verb::
- patch)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ boost::beast::http::verb::patch)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::optional<std::string> newHostName;
std::optional<nlohmann::json> ntp;
std::optional<nlohmann::json> ipmi;
@@ -484,8 +490,12 @@ inline void requestRoutesNetworkProtocol(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Managers/bmc/NetworkProtocol/")
.privileges(redfish::privileges::getManagerNetworkProtocol)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
getNetworkData(asyncResp, req);
});
}
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index ca1eb8f9fd..fdc2af24d4 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -19,6 +19,7 @@
#include <app.hpp>
#include <boost/system/linux_error.hpp>
#include <dbus_utility.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
namespace redfish
@@ -81,10 +82,12 @@ inline void requestRoutesSystemPCIeDeviceCollection(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/PCIeDevices/")
.privileges(redfish::privileges::getPCIeDeviceCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
-
- {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue = {
{"@odata.type",
"#PCIeDeviceCollection.PCIeDeviceCollection"},
@@ -140,112 +143,113 @@ inline void requestRoutesSystemPCIeDevice(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/PCIeDevices/<str>/")
.privileges(redfish::privileges::getPCIeDevice)
- .methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& device)
-
+ .methods(
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& device) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
{
- auto getPCIeDeviceCallback =
- [asyncResp, device](const boost::system::error_code ec,
- const dbus::utility::DBusPropertiesMap&
- pcieDevProperties) {
- if (ec)
+ return;
+ }
+ auto getPCIeDeviceCallback =
+ [asyncResp, device](
+ const boost::system::error_code ec,
+ const dbus::utility::DBusPropertiesMap& pcieDevProperties) {
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG
+ << "failed to get PCIe Device properties ec: "
+ << ec.value() << ": " << ec.message();
+ if (ec.value() ==
+ boost::system::linux_error::bad_request_descriptor)
{
- BMCWEB_LOG_DEBUG
- << "failed to get PCIe Device properties ec: "
- << ec.value() << ": " << ec.message();
- if (ec.value() == boost::system::linux_error::
- bad_request_descriptor)
+ messages::resourceNotFound(asyncResp->res,
+ "PCIeDevice", device);
+ }
+ else
+ {
+ messages::internalError(asyncResp->res);
+ }
+ return;
+ }
+
+ asyncResp->res.jsonValue = {
+ {"@odata.type", "#PCIeDevice.v1_4_0.PCIeDevice"},
+ {"@odata.id",
+ "/redfish/v1/Systems/system/PCIeDevices/" + device},
+ {"Name", "PCIe Device"},
+ {"Id", device}};
+ asyncResp->res.jsonValue["PCIeFunctions"] = {
+ {"@odata.id",
+ "/redfish/v1/Systems/system/PCIeDevices/" + device +
+ "/PCIeFunctions"}};
+ for (const auto& property : pcieDevProperties)
+ {
+ const std::string* propertyString =
+ std::get_if<std::string>(&property.second);
+ if (property.first == "Manufacturer")
+ {
+ if (propertyString == nullptr)
{
- messages::resourceNotFound(
- asyncResp->res, "PCIeDevice", device);
+ messages::internalError(asyncResp->res);
+ return;
}
- else
+ asyncResp->res.jsonValue["Manufacturer"] =
+ *propertyString;
+ }
+ if (property.first == "DeviceType")
+ {
+ if (propertyString == nullptr)
{
messages::internalError(asyncResp->res);
+ return;
}
- return;
+ asyncResp->res.jsonValue["DeviceType"] =
+ *propertyString;
}
-
- asyncResp->res.jsonValue = {
- {"@odata.type", "#PCIeDevice.v1_4_0.PCIeDevice"},
- {"@odata.id",
- "/redfish/v1/Systems/system/PCIeDevices/" +
- device},
- {"Name", "PCIe Device"},
- {"Id", device}};
- asyncResp->res.jsonValue["PCIeFunctions"] = {
- {"@odata.id",
- "/redfish/v1/Systems/system/PCIeDevices/" +
- device + "/PCIeFunctions"}};
- for (const auto& property : pcieDevProperties)
+ if (property.first == "DeviceType")
{
- const std::string* propertyString =
- std::get_if<std::string>(&property.second);
- if (property.first == "Manufacturer")
+ if (propertyString == nullptr)
{
- if (propertyString == nullptr)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res.jsonValue["Manufacturer"] =
- *propertyString;
+ messages::internalError(asyncResp->res);
+ return;
}
- if (property.first == "DeviceType")
+ asyncResp->res.jsonValue["DeviceType"] =
+ *propertyString;
+ }
+ if (property.first == "GenerationInUse")
+ {
+ if (propertyString == nullptr)
{
- if (propertyString == nullptr)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res.jsonValue["DeviceType"] =
- *propertyString;
+ messages::internalError(asyncResp->res);
+ return;
}
- if (property.first == "DeviceType")
+ std::optional<std::string> generationInUse =
+ redfishPcieGenerationFromDbus(*propertyString);
+ if (!generationInUse)
{
- if (propertyString == nullptr)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- asyncResp->res.jsonValue["DeviceType"] =
- *propertyString;
+ messages::internalError(asyncResp->res);
+ return;
}
- if (property.first == "GenerationInUse")
+ if (generationInUse->empty())
{
- if (propertyString == nullptr)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- std::optional<std::string> generationInUse =
- redfishPcieGenerationFromDbus(
- *propertyString);
- if (!generationInUse)
- {
- messages::internalError(asyncResp->res);
- return;
- }
- if (generationInUse->empty())
- {
- // unknown, no need to handle
- return;
- }
- asyncResp->res
- .jsonValue["PCIeInterface"]["PCIeType"] =
- *generationInUse;
+ // unknown, no need to handle
+ return;
}
+ asyncResp->res
+ .jsonValue["PCIeInterface"]["PCIeType"] =
+ *generationInUse;
}
- };
- std::string escapedPath = std::string(pciePath) + "/" + device;
- dbus::utility::escapePathForDbus(escapedPath);
- crow::connections::systemBus->async_method_call(
- std::move(getPCIeDeviceCallback), pcieService, escapedPath,
- "org.freedesktop.DBus.Properties", "GetAll",
- pcieDeviceInterface);
- });
+ }
+ };
+ std::string escapedPath = std::string(pciePath) + "/" + device;
+ dbus::utility::escapePathForDbus(escapedPath);
+ crow::connections::systemBus->async_method_call(
+ std::move(getPCIeDeviceCallback), pcieService, escapedPath,
+ "org.freedesktop.DBus.Properties", "GetAll",
+ pcieDeviceInterface);
+ });
}
inline void requestRoutesSystemPCIeFunctionCollection(App& app)
@@ -256,84 +260,87 @@ inline void requestRoutesSystemPCIeFunctionCollection(App& app)
BMCWEB_ROUTE(app,
"/redfish/v1/Systems/system/PCIeDevices/<str>/PCIeFunctions/")
.privileges(redfish::privileges::getPCIeFunctionCollection)
- .methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& device)
-
+ .methods(
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& device) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
{
- asyncResp->res.jsonValue = {
- {"@odata.type",
- "#PCIeFunctionCollection.PCIeFunctionCollection"},
- {"@odata.id", "/redfish/v1/Systems/system/PCIeDevices/" +
- device + "/PCIeFunctions"},
- {"Name", "PCIe Function Collection"},
- {"Description",
- "Collection of PCIe Functions for PCIe Device " + device}};
+ return;
+ }
+ asyncResp->res.jsonValue = {
+ {"@odata.type",
+ "#PCIeFunctionCollection.PCIeFunctionCollection"},
+ {"@odata.id", "/redfish/v1/Systems/system/PCIeDevices/" +
+ device + "/PCIeFunctions"},
+ {"Name", "PCIe Function Collection"},
+ {"Description",
+ "Collection of PCIe Functions for PCIe Device " + device}};
- auto getPCIeDeviceCallback =
- [asyncResp, device](const boost::system::error_code ec,
- const dbus::utility::DBusPropertiesMap&
- pcieDevProperties) {
- if (ec)
+ auto getPCIeDeviceCallback =
+ [asyncResp, device](
+ const boost::system::error_code ec,
+ const dbus::utility::DBusPropertiesMap& pcieDevProperties) {
+ if (ec)
+ {
+ BMCWEB_LOG_DEBUG
+ << "failed to get PCIe Device properties ec: "
+ << ec.value() << ": " << ec.message();
+ if (ec.value() ==
+ boost::system::linux_error::bad_request_descriptor)
{
- BMCWEB_LOG_DEBUG
- << "failed to get PCIe Device properties ec: "
- << ec.value() << ": " << ec.message();
- if (ec.value() == boost::system::linux_error::
- bad_request_descriptor)
- {
- messages::resourceNotFound(
- asyncResp->res, "PCIeDevice", device);
- }
- else
- {
- messages::internalError(asyncResp->res);
- }
- return;
+ messages::resourceNotFound(asyncResp->res,
+ "PCIeDevice", device);
+ }
+ else
+ {
+ messages::internalError(asyncResp->res);
}
+ return;
+ }
- nlohmann::json& pcieFunctionList =
- asyncResp->res.jsonValue["Members"];
- pcieFunctionList = nlohmann::json::array();
- static constexpr const int maxPciFunctionNum = 8;
- for (int functionNum = 0;
- functionNum < maxPciFunctionNum; functionNum++)
+ nlohmann::json& pcieFunctionList =
+ asyncResp->res.jsonValue["Members"];
+ pcieFunctionList = nlohmann::json::array();
+ static constexpr const int maxPciFunctionNum = 8;
+ for (int functionNum = 0; functionNum < maxPciFunctionNum;
+ functionNum++)
+ {
+ // Check if this function exists by looking for a
+ // device ID
+ std::string devIDProperty =
+ "Function" + std::to_string(functionNum) +
+ "DeviceId";
+ const std::string* property = nullptr;
+ for (const auto& propEntry : pcieDevProperties)
{
- // Check if this function exists by looking for a
- // device ID
- std::string devIDProperty =
- "Function" + std::to_string(functionNum) +
- "DeviceId";
- const std::string* property = nullptr;
- for (const auto& propEntry : pcieDevProperties)
+ if (propEntry.first == devIDProperty)
{
- if (propEntry.first == devIDProperty)
- {
- property = std::get_if<std::string>(
- &propEntry.second);
- }
+ property =
+ std::get_if<std::string>(&propEntry.second);
}
- if (property == nullptr || !property->empty())
- {
- return;
- }
- pcieFunctionList.push_back(
- {{"@odata.id",
- "/redfish/v1/Systems/system/PCIeDevices/" +
- device + "/PCIeFunctions/" +
- std::to_string(functionNum)}});
}
- asyncResp->res.jsonValue["Members@odata.count"] =
- pcieFunctionList.size();
- };
- std::string escapedPath = std::string(pciePath) + "/" + device;
- dbus::utility::escapePathForDbus(escapedPath);
- crow::connections::systemBus->async_method_call(
- std::move(getPCIeDeviceCallback), pcieService, escapedPath,
- "org.freedesktop.DBus.Properties", "GetAll",
- pcieDeviceInterface);
- });
+ if (property == nullptr || !property->empty())
+ {
+ return;
+ }
+ pcieFunctionList.push_back(
+ {{"@odata.id",
+ "/redfish/v1/Systems/system/PCIeDevices/" +
+ device + "/PCIeFunctions/" +
+ std::to_string(functionNum)}});
+ }
+ asyncResp->res.jsonValue["Members@odata.count"] =
+ pcieFunctionList.size();
+ };
+ std::string escapedPath = std::string(pciePath) + "/" + device;
+ dbus::utility::escapePathForDbus(escapedPath);
+ crow::connections::systemBus->async_method_call(
+ std::move(getPCIeDeviceCallback), pcieService, escapedPath,
+ "org.freedesktop.DBus.Properties", "GetAll",
+ pcieDeviceInterface);
+ });
}
inline void requestRoutesSystemPCIeFunction(App& app)
@@ -343,11 +350,15 @@ inline void requestRoutesSystemPCIeFunction(App& app)
"/redfish/v1/Systems/system/PCIeDevices/<str>/PCIeFunctions/<str>/")
.privileges(redfish::privileges::getPCIeFunction)
.methods(
- boost::beast::http::verb::get)([](const crow::Request&,
- const std::shared_ptr<
- bmcweb::AsyncResp>& asyncResp,
- const std::string& device,
- const std::string& function) {
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& device,
+ const std::string& function) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
auto getPCIeDeviceCallback =
[asyncResp, device, function](
const boost::system::error_code ec,
diff --git a/redfish-core/lib/power.hpp b/redfish-core/lib/power.hpp
index dd67aea06f..8eacb9bb17 100644
--- a/redfish-core/lib/power.hpp
+++ b/redfish-core/lib/power.hpp
@@ -20,6 +20,7 @@
#include <app.hpp>
#include <dbus_utility.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
namespace redfish
@@ -119,10 +120,14 @@ inline void requestRoutesPower(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Power/")
.privileges(redfish::privileges::getPower)
.methods(
- boost::beast::http::verb::get)([](const crow::Request&,
- const std::shared_ptr<
- bmcweb::AsyncResp>& asyncResp,
- const std::string& chassisName) {
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& chassisName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["PowerControl"] = nlohmann::json::array();
auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>(
@@ -309,9 +314,13 @@ inline void requestRoutesPower(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Power/")
.privileges(redfish::privileges::patchPower)
.methods(boost::beast::http::verb::patch)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& chassisName) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& chassisName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
auto sensorAsyncResp = std::make_shared<SensorsAsyncResp>(
asyncResp, chassisName,
sensors::dbus::paths.at(sensors::node::power),
diff --git a/redfish-core/lib/processor.hpp b/redfish-core/lib/processor.hpp
index f304eb86c0..2a0e028b87 100644
--- a/redfish-core/lib/processor.hpp
+++ b/redfish-core/lib/processor.hpp
@@ -22,6 +22,7 @@
#include <app.hpp>
#include <boost/container/flat_map.hpp>
#include <dbus_utility.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <sdbusplus/asio/property.hpp>
#include <sdbusplus/message/native_types.hpp>
@@ -1056,10 +1057,14 @@ inline void requestRoutesOperatingConfigCollection(App& app)
app, "/redfish/v1/Systems/system/Processors/<str>/OperatingConfigs/")
.privileges(redfish::privileges::getOperatingConfigCollection)
.methods(
- boost::beast::http::verb::get)([](const crow::Request& req,
- const std::shared_ptr<
- bmcweb::AsyncResp>& asyncResp,
- const std::string& cpuName) {
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& cpuName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#OperatingConfigCollection.OperatingConfigCollection";
asyncResp->res.jsonValue["@odata.id"] = req.url;
@@ -1118,11 +1123,15 @@ inline void requestRoutesOperatingConfig(App& app)
"/redfish/v1/Systems/system/Processors/<str>/OperatingConfigs/<str>/")
.privileges(redfish::privileges::getOperatingConfig)
.methods(
- boost::beast::http::verb::get)([](const crow::Request& req,
- const std::shared_ptr<
- bmcweb::AsyncResp>& asyncResp,
- const std::string& cpuName,
- const std::string& configName) {
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& cpuName,
+ const std::string& configName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
// Ask for all objects implementing OperatingConfig so we can search
// for one with a matching name
crow::connections::systemBus->async_method_call(
@@ -1181,8 +1190,12 @@ inline void requestRoutesProcessorCollection(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Processors/")
.privileges(redfish::privileges::getProcessorCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#ProcessorCollection.ProcessorCollection";
asyncResp->res.jsonValue["Name"] = "Processor Collection";
@@ -1206,9 +1219,13 @@ inline void requestRoutesProcessor(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Processors/<str>/")
.privileges(redfish::privileges::getProcessor)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& processorId) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& processorId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#Processor.v1_11_0.Processor";
asyncResp->res.jsonValue["@odata.id"] =
@@ -1220,9 +1237,13 @@ inline void requestRoutesProcessor(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Processors/<str>/")
.privileges(redfish::privileges::patchProcessor)
.methods(boost::beast::http::verb::patch)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& processorId) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& processorId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::optional<nlohmann::json> appliedConfigJson;
if (!json_util::readJsonPatch(req, asyncResp->res,
"AppliedOperatingConfig",
diff --git a/redfish-core/lib/redfish_sessions.hpp b/redfish-core/lib/redfish_sessions.hpp
index 3c2247bbd4..6c55f75215 100644
--- a/redfish-core/lib/redfish_sessions.hpp
+++ b/redfish-core/lib/redfish_sessions.hpp
@@ -20,6 +20,7 @@
#include <app.hpp>
#include <http/utility.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
namespace redfish
@@ -44,10 +45,14 @@ inline void fillSessionObject(crow::Response& res,
}
inline void
- handleSessionGet(const crow::Request& /*req*/,
+ handleSessionGet(crow::App& app, const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& sessionId)
{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
// Note that control also reaches here via doPost and doDelete.
auto session =
persistent_data::SessionStore::getInstance().getSessionByUid(sessionId);
@@ -62,10 +67,14 @@ inline void
}
inline void
- handleSessionDelete(const crow::Request& req,
+ handleSessionDelete(crow::App& app, const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const std::string& sessionId)
{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
auto session =
persistent_data::SessionStore::getInstance().getSessionByUid(sessionId);
@@ -111,9 +120,13 @@ inline nlohmann::json getSessionCollectionMembers()
}
inline void handleSessionCollectionGet(
- const crow::Request& /*req*/,
+ crow::App& app, const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["Members"] = getSessionCollectionMembers();
asyncResp->res.jsonValue["Members@odata.count"] =
asyncResp->res.jsonValue["Members"].size();
@@ -126,16 +139,24 @@ inline void handleSessionCollectionGet(
}
inline void handleSessionCollectionMembersGet(
- const crow::Request& /*req*/,
+ crow::App& app, const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue = getSessionCollectionMembers();
}
void handleSessionCollectionPost(
- const crow::Request& req,
+ crow::App& app, const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::string username;
std::string password;
std::optional<nlohmann::json> oemObject;
@@ -206,10 +227,14 @@ void handleSessionCollectionPost(
fillSessionObject(asyncResp->res, *session);
}
inline void
- handleSessionServiceGet(const crow::Request& /* req */,
+ handleSessionServiceGet(crow::App& app, const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#SessionService.v1_0_2.SessionService";
asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/SessionService/";
@@ -225,9 +250,13 @@ inline void
}
inline void handleSessionServicePatch(
- const crow::Request& req,
+ crow::App& app, const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::optional<int64_t> sessionTimeout;
if (!json_util::readJsonPatch(req, asyncResp->res, "SessionTimeout",
sessionTimeout))
@@ -263,15 +292,18 @@ inline void requestRoutesSession(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/<str>/")
.privileges(redfish::privileges::getSession)
- .methods(boost::beast::http::verb::get)(handleSessionGet);
+ .methods(boost::beast::http::verb::get)(
+ std::bind_front(handleSessionGet, std::ref(app)));
BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/<str>/")
.privileges(redfish::privileges::deleteSession)
- .methods(boost::beast::http::verb::delete_)(handleSessionDelete);
+ .methods(boost::beast::http::verb::delete_)(
+ std::bind_front(handleSessionDelete, std::ref(app)));
BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/")
.privileges(redfish::privileges::getSessionCollection)
- .methods(boost::beast::http::verb::get)(handleSessionCollectionGet);
+ .methods(boost::beast::http::verb::get)(
+ std::bind_front(handleSessionCollectionGet, std::ref(app)));
// Note, the next two routes technically don't match the privilege
// registry given the way login mechanisms work. The base privilege
@@ -280,19 +312,23 @@ inline void requestRoutesSession(App& app)
// is itself its own route, it needs to not require Login
BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/")
.privileges({})
- .methods(boost::beast::http::verb::post)(handleSessionCollectionPost);
+ .methods(boost::beast::http::verb::post)(
+ std::bind_front(handleSessionCollectionPost, std::ref(app)));
BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/Members/")
.privileges({})
- .methods(boost::beast::http::verb::post)(handleSessionCollectionPost);
+ .methods(boost::beast::http::verb::post)(
+ std::bind_front(handleSessionCollectionPost, std::ref(app)));
BMCWEB_ROUTE(app, "/redfish/v1/SessionService/")
.privileges(redfish::privileges::getSessionService)
- .methods(boost::beast::http::verb::get)(handleSessionServiceGet);
+ .methods(boost::beast::http::verb::get)(
+ std::bind_front(handleSessionServiceGet, std::ref(app)));
BMCWEB_ROUTE(app, "/redfish/v1/SessionService/")
.privileges(redfish::privileges::patchSessionService)
- .methods(boost::beast::http::verb::patch)(handleSessionServicePatch);
+ .methods(boost::beast::http::verb::patch)(
+ std::bind_front(handleSessionServicePatch, std::ref(app)));
}
} // namespace redfish
diff --git a/redfish-core/lib/roles.hpp b/redfish-core/lib/roles.hpp
index 6c67a33f81..dd8a790800 100644
--- a/redfish-core/lib/roles.hpp
+++ b/redfish-core/lib/roles.hpp
@@ -17,6 +17,7 @@
#include <app.hpp>
#include <dbus_utility.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <sdbusplus/asio/property.hpp>
@@ -77,9 +78,13 @@ inline void requestRoutesRoles(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/AccountService/Roles/<str>/")
.privileges(redfish::privileges::getRole)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& roleId) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& roleId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
nlohmann::json privArray = nlohmann::json::array();
if (!getAssignedPrivFromRole(roleId, privArray))
{
@@ -106,8 +111,12 @@ inline void requestRoutesRoleCollection(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/AccountService/Roles/")
.privileges(redfish::privileges::getRoleCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue = {
{"@odata.id", "/redfish/v1/AccountService/Roles"},
{"@odata.type", "#RoleCollection.RoleCollection"},
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index d501b70022..25ac5e0448 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -22,6 +22,7 @@
#include <boost/range/algorithm/replace_copy_if.hpp>
#include <dbus_singleton.hpp>
#include <dbus_utility.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <sdbusplus/asio/property.hpp>
#include <utils/json_utils.hpp>
@@ -2924,56 +2925,62 @@ inline void requestRoutesSensorCollection(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Sensors/")
.privileges(redfish::privileges::getSensorCollection)
- .methods(
- boost::beast::http::verb::get)([](const crow::Request&,
- const std::shared_ptr<
- bmcweb::AsyncResp>& aResp,
- const std::string& chassisId) {
- BMCWEB_LOG_DEBUG << "SensorCollection doGet enter";
+ .methods(boost::beast::http::verb::get)(
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& aResp,
+ const std::string& chassisId) {
+ if (!redfish::setUpRedfishRoute(app, req, aResp->res))
+ {
+ return;
+ }
- std::shared_ptr<SensorsAsyncResp> asyncResp =
- std::make_shared<SensorsAsyncResp>(
- aResp, chassisId,
- sensors::dbus::paths.at(sensors::node::sensors),
- sensors::node::sensors);
+ BMCWEB_LOG_DEBUG << "SensorCollection doGet enter";
- auto getChassisCb =
- [asyncResp](
- const std::shared_ptr<
- boost::container::flat_set<std::string>>& sensorNames) {
- BMCWEB_LOG_DEBUG << "getChassisCb enter";
+ std::shared_ptr<SensorsAsyncResp> asyncResp =
+ std::make_shared<SensorsAsyncResp>(
+ aResp, chassisId,
+ sensors::dbus::paths.at(sensors::node::sensors),
+ sensors::node::sensors);
- nlohmann::json& entriesArray =
- asyncResp->asyncResp->res.jsonValue["Members"];
- for (auto& sensor : *sensorNames)
- {
- BMCWEB_LOG_DEBUG << "Adding sensor: " << sensor;
+ auto getChassisCb =
+ [asyncResp](const std::shared_ptr<
+ boost::container::flat_set<std::string>>&
+ sensorNames) {
+ BMCWEB_LOG_DEBUG << "getChassisCb enter";
- sdbusplus::message::object_path path(sensor);
- std::string sensorName = path.filename();
- if (sensorName.empty())
+ nlohmann::json& entriesArray =
+ asyncResp->asyncResp->res.jsonValue["Members"];
+ for (auto& sensor : *sensorNames)
{
- BMCWEB_LOG_ERROR << "Invalid sensor path: "
- << sensor;
- messages::internalError(asyncResp->asyncResp->res);
- return;
+ BMCWEB_LOG_DEBUG << "Adding sensor: " << sensor;
+
+ sdbusplus::message::object_path path(sensor);
+ std::string sensorName = path.filename();
+ if (sensorName.empty())
+ {
+ BMCWEB_LOG_ERROR << "Invalid sensor path: "
+ << sensor;
+ messages::internalError(
+ asyncResp->asyncResp->res);
+ return;
+ }
+ entriesArray.push_back(
+ {{"@odata.id", "/redfish/v1/Chassis/" +
+ asyncResp->chassisId + "/" +
+ asyncResp->chassisSubNode +
+ "/" + sensorName}});
}
- entriesArray.push_back(
- {{"@odata.id", "/redfish/v1/Chassis/" +
- asyncResp->chassisId + "/" +
- asyncResp->chassisSubNode + "/" +
- sensorName}});
- }
- asyncResp->asyncResp->res.jsonValue["Members@odata.count"] =
- entriesArray.size();
- BMCWEB_LOG_DEBUG << "getChassisCb exit";
- };
+ asyncResp->asyncResp->res
+ .jsonValue["Members@odata.count"] =
+ entriesArray.size();
+ BMCWEB_LOG_DEBUG << "getChassisCb exit";
+ };
- // Get set of sensors in chassis
- getChassis(asyncResp, std::move(getChassisCb));
- BMCWEB_LOG_DEBUG << "SensorCollection doGet exit";
- });
+ // Get set of sensors in chassis
+ getChassis(asyncResp, std::move(getChassisCb));
+ BMCWEB_LOG_DEBUG << "SensorCollection doGet exit";
+ });
}
inline void requestRoutesSensor(App& app)
@@ -2981,11 +2988,16 @@ inline void requestRoutesSensor(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Sensors/<str>/")
.privileges(redfish::privileges::getSensor)
.methods(
- boost::beast::http::verb::get)([](const crow::Request&,
- const std::shared_ptr<
- bmcweb::AsyncResp>& aResp,
- const std::string& chassisId,
- const std::string& sensorName) {
+ boost::beast::http::verb::get)([&app](
+ const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>& aResp,
+ const std::string& chassisId,
+ const std::string& sensorName) {
+ if (!redfish::setUpRedfishRoute(app, req, aResp->res))
+ {
+ return;
+ }
BMCWEB_LOG_DEBUG << "Sensor doGet enter";
std::shared_ptr<SensorsAsyncResp> asyncResp =
std::make_shared<SensorsAsyncResp>(aResp, chassisId,
diff --git a/redfish-core/lib/storage.hpp b/redfish-core/lib/storage.hpp
index 6809958e05..7f1e0de7b2 100644
--- a/redfish-core/lib/storage.hpp
+++ b/redfish-core/lib/storage.hpp
@@ -20,6 +20,7 @@
#include <app.hpp>
#include <dbus_utility.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <sdbusplus/asio/property.hpp>
@@ -30,8 +31,12 @@ inline void requestRoutesStorageCollection(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Storage/")
.privileges(redfish::privileges::getStorageCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#StorageCollection.StorageCollection";
asyncResp->res.jsonValue["@odata.id"] =
@@ -47,10 +52,14 @@ inline void requestRoutesStorage(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Storage/1/")
.privileges(redfish::privileges::getStorage)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] = "#Storage.v1_7_1.Storage";
asyncResp->res.jsonValue["@odata.id"] =
"/redfish/v1/Systems/system/Storage/1";
@@ -477,10 +486,14 @@ inline void requestRoutesDrive(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/Storage/1/Drives/<str>/")
.privileges(redfish::privileges::getDrive)
.methods(
- boost::beast::http::verb::get)([](const crow::Request&,
- const std::shared_ptr<
- bmcweb::AsyncResp>& asyncResp,
- const std::string& driveId) {
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& driveId) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
crow::connections::systemBus->async_method_call(
[asyncResp, driveId](
const boost::system::error_code ec,
diff --git a/redfish-core/lib/systems.hpp b/redfish-core/lib/systems.hpp
index 83f9dadf3e..b619513357 100644
--- a/redfish-core/lib/systems.hpp
+++ b/redfish-core/lib/systems.hpp
@@ -2731,8 +2731,13 @@ inline void requestRoutesSystemActionsReset(App& app)
.privileges(redfish::privileges::postComputerSystem)
.methods(
boost::beast::http::verb::
- post)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ post)([&app](
+ const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::string resetType;
if (!json_util::readJsonAction(req, asyncResp->res, "ResetType",
resetType))
@@ -2856,10 +2861,14 @@ inline void requestRoutesSystems(App& app)
*/
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/")
.privileges(redfish::privileges::getComputerSystem)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#ComputerSystem.v1_16_0.ComputerSystem";
asyncResp->res.jsonValue["Name"] = "system";
@@ -2979,8 +2988,12 @@ inline void requestRoutesSystems(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/")
.privileges(redfish::privileges::patchComputerSystem)
.methods(boost::beast::http::verb::patch)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::optional<bool> locationIndicatorActive;
std::optional<std::string> indicatorLed;
std::optional<nlohmann::json> bootProps;
@@ -3121,8 +3134,12 @@ inline void requestRoutesSystemResetActionInfo(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Systems/system/ResetActionInfo/")
.privileges(redfish::privileges::getActionInfo)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue = {
{"@odata.type", "#ActionInfo.v1_1_2.ActionInfo"},
{"@odata.id", "/redfish/v1/Systems/system/ResetActionInfo"},
diff --git a/redfish-core/lib/task.hpp b/redfish-core/lib/task.hpp
index 6c0a4b61fe..199bc84b7d 100644
--- a/redfish-core/lib/task.hpp
+++ b/redfish-core/lib/task.hpp
@@ -19,6 +19,7 @@
#include <boost/asio/post.hpp>
#include <boost/asio/steady_timer.hpp>
#include <dbus_utility.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <task_messages.hpp>
@@ -319,9 +320,13 @@ inline void requestRoutesTaskMonitor(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/TaskService/Tasks/<str>/Monitor/")
.privileges(redfish::privileges::getTask)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& strParam) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& strParam) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
auto find = std::find_if(
task::tasks.begin(), task::tasks.end(),
[&strParam](const std::shared_ptr<task::TaskData>& task) {
@@ -358,9 +363,13 @@ inline void requestRoutesTask(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/TaskService/Tasks/<str>/")
.privileges(redfish::privileges::getTask)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& strParam) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& strParam) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
auto find = std::find_if(
task::tasks.begin(), task::tasks.end(),
[&strParam](const std::shared_ptr<task::TaskData>& task) {
@@ -426,8 +435,12 @@ inline void requestRoutesTaskCollection(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/TaskService/Tasks/")
.privileges(redfish::privileges::getTaskCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#TaskCollection.TaskCollection";
asyncResp->res.jsonValue["@odata.id"] =
@@ -456,8 +469,12 @@ inline void requestRoutesTaskService(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/TaskService/")
.privileges(redfish::privileges::getTaskService)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#TaskService.v1_1_4.TaskService";
asyncResp->res.jsonValue["@odata.id"] =
diff --git a/redfish-core/lib/telemetry_service.hpp b/redfish-core/lib/telemetry_service.hpp
index e0f6c03819..7cdc497a65 100644
--- a/redfish-core/lib/telemetry_service.hpp
+++ b/redfish-core/lib/telemetry_service.hpp
@@ -4,15 +4,20 @@
#include <app.hpp>
#include <dbus_utility.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
namespace redfish
{
inline void handleTelemetryServiceGet(
- const crow::Request& /*req*/,
+ crow::App& app, const crow::Request& req,
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#TelemetryService.v1_2_1.TelemetryService";
asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/TelemetryService";
@@ -78,7 +83,8 @@ inline void requestRoutesTelemetryService(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/TelemetryService/")
.privileges(redfish::privileges::getTelemetryService)
- .methods(boost::beast::http::verb::get)(handleTelemetryServiceGet);
+ .methods(boost::beast::http::verb::get)(
+ std::bind_front(handleTelemetryServiceGet, std::ref(app)));
}
} // namespace redfish
diff --git a/redfish-core/lib/thermal.hpp b/redfish-core/lib/thermal.hpp
index c49bb0bd4d..847d17043c 100644
--- a/redfish-core/lib/thermal.hpp
+++ b/redfish-core/lib/thermal.hpp
@@ -18,6 +18,7 @@
#include "sensors.hpp"
#include <app.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
namespace redfish
@@ -28,9 +29,14 @@ inline void requestRoutesThermal(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Thermal/")
.privileges(redfish::privileges::getThermal)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& chassisName) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& chassisName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+
auto thermalPaths =
sensors::dbus::paths.find(sensors::node::thermal);
if (thermalPaths == sensors::dbus::paths.end())
@@ -50,9 +56,14 @@ inline void requestRoutesThermal(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Chassis/<str>/Thermal/")
.privileges(redfish::privileges::patchThermal)
.methods(boost::beast::http::verb::patch)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& chassisName) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& chassisName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+
auto thermalPaths =
sensors::dbus::paths.find(sensors::node::thermal);
if (thermalPaths == sensors::dbus::paths.end())
diff --git a/redfish-core/lib/trigger.hpp b/redfish-core/lib/trigger.hpp
index da6a5dbbc8..e2f46ecef2 100644
--- a/redfish-core/lib/trigger.hpp
+++ b/redfish-core/lib/trigger.hpp
@@ -4,6 +4,7 @@
#include "utils/telemetry_utils.hpp"
#include <app.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <tuple>
@@ -282,8 +283,12 @@ inline void requestRoutesTriggerCollection(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/TelemetryService/Triggers/")
.privileges(redfish::privileges::getTriggersCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#TriggersCollection.TriggersCollection";
asyncResp->res.jsonValue["@odata.id"] = telemetry::triggerUri;
@@ -301,9 +306,13 @@ inline void requestRoutesTrigger(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/TelemetryService/Triggers/<str>/")
.privileges(redfish::privileges::getTriggers)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& id) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& id) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
crow::connections::systemBus->async_method_call(
[asyncResp,
id](const boost::system::error_code ec,
@@ -338,9 +347,13 @@ inline void requestRoutesTrigger(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/TelemetryService/Triggers/<str>/")
.privileges(redfish::privileges::deleteTriggers)
.methods(boost::beast::http::verb::delete_)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& id) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& id) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
const std::string triggerPath =
telemetry::getDbusTriggerPath(id);
diff --git a/redfish-core/lib/update_service.hpp b/redfish-core/lib/update_service.hpp
index 729aa564fa..70fe8dbd20 100644
--- a/redfish-core/lib/update_service.hpp
+++ b/redfish-core/lib/update_service.hpp
@@ -19,6 +19,7 @@
#include <app.hpp>
#include <dbus_utility.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <sdbusplus/asio/property.hpp>
#include <utils/fw_utils.hpp>
@@ -416,8 +417,14 @@ inline void requestRoutesUpdateServiceActionsSimpleUpdate(App& app)
.privileges(redfish::privileges::postUpdateService)
.methods(
boost::beast::http::verb::
- post)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ post)([&app](
+ const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
+
std::optional<std::string> transferProtocol;
std::string imageURI;
@@ -534,10 +541,14 @@ inline void requestRoutesUpdateService(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/UpdateService/")
.privileges(redfish::privileges::getUpdateService)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#UpdateService.v1_5_0.UpdateService";
asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/UpdateService";
@@ -602,9 +613,14 @@ inline void requestRoutesUpdateService(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/UpdateService/")
.privileges(redfish::privileges::patchUpdateService)
.methods(
- boost::beast::http::verb::
- patch)([](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ boost::beast::http::verb::patch)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
BMCWEB_LOG_DEBUG << "doPatch...";
std::optional<nlohmann::json> pushUriOptions;
@@ -680,8 +696,12 @@ inline void requestRoutesUpdateService(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/UpdateService/")
.privileges(redfish::privileges::postUpdateService)
.methods(boost::beast::http::verb::post)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
BMCWEB_LOG_DEBUG << "doPost...";
// Setup callback for when new software detected
@@ -705,10 +725,14 @@ inline void requestRoutesSoftwareInventoryCollection(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/UpdateService/FirmwareInventory/")
.privileges(redfish::privileges::getSoftwareInventoryCollection)
- .methods(
- boost::beast::http::verb::
- get)([](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
+ .methods(boost::beast::http::verb::get)([&app](const crow::Request& req,
+ const std::shared_ptr<
+ bmcweb::AsyncResp>&
+ asyncResp) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
asyncResp->res.jsonValue["@odata.type"] =
"#SoftwareInventoryCollection.SoftwareInventoryCollection";
asyncResp->res.jsonValue["@odata.id"] =
@@ -791,10 +815,14 @@ inline void requestRoutesSoftwareInventory(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/UpdateService/FirmwareInventory/<str>/")
.privileges(redfish::privileges::getSoftwareInventory)
.methods(
- boost::beast::http::verb::get)([](const crow::Request&,
- const std::shared_ptr<
- bmcweb::AsyncResp>& asyncResp,
- const std::string& param) {
+ boost::beast::http::verb::
+ get)([&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& param) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
std::shared_ptr<std::string> swId =
std::make_shared<std::string>(param);
diff --git a/redfish-core/lib/virtual_media.hpp b/redfish-core/lib/virtual_media.hpp
index 7159be15a3..e94e233964 100644
--- a/redfish-core/lib/virtual_media.hpp
+++ b/redfish-core/lib/virtual_media.hpp
@@ -20,6 +20,7 @@
#include <boost/process/async_pipe.hpp>
#include <boost/type_traits/has_dereference.hpp>
#include <boost/url/url_view.hpp>
+#include <query.hpp>
#include <registries/privilege_registry.hpp>
#include <utils/json_utils.hpp>
@@ -778,9 +779,13 @@ inline void requestNBDVirtualMediaRoutes(App& app)
"/redfish/v1/Managers/<str>/VirtualMedia/<str>/Actions/VirtualMedia.InsertMedia")
.privileges(redfish::privileges::postVirtualMedia)
.methods(boost::beast::http::verb::post)(
- [](const crow::Request& req,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& name, const std::string& resName) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& name, const std::string& resName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
if (name != "bmc")
{
messages::resourceNotFound(asyncResp->res,
@@ -913,9 +918,13 @@ inline void requestNBDVirtualMediaRoutes(App& app)
"/redfish/v1/Managers/<str>/VirtualMedia/<str>/Actions/VirtualMedia.EjectMedia")
.privileges(redfish::privileges::postVirtualMedia)
.methods(boost::beast::http::verb::post)(
- [](const crow::Request&,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& name, const std::string& resName) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& name, const std::string& resName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
if (name != "bmc")
{
messages::resourceNotFound(asyncResp->res,
@@ -1003,9 +1012,13 @@ inline void requestNBDVirtualMediaRoutes(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/VirtualMedia/")
.privileges(redfish::privileges::getVirtualMediaCollection)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request& /* req */,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& name) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& name) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
if (name != "bmc")
{
messages::resourceNotFound(asyncResp->res, "VirtualMedia",
@@ -1048,9 +1061,13 @@ inline void requestNBDVirtualMediaRoutes(App& app)
BMCWEB_ROUTE(app, "/redfish/v1/Managers/<str>/VirtualMedia/<str>/")
.privileges(redfish::privileges::getVirtualMedia)
.methods(boost::beast::http::verb::get)(
- [](const crow::Request& /* req */,
- const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
- const std::string& name, const std::string& resName) {
+ [&app](const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
+ const std::string& name, const std::string& resName) {
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp->res))
+ {
+ return;
+ }
if (name != "bmc")
{
messages::resourceNotFound(asyncResp->res, "VirtualMedia",