summaryrefslogtreecommitdiff
path: root/redfish-core/lib/bios.hpp
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/lib/bios.hpp
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/lib/bios.hpp')
-rw-r--r--redfish-core/lib/bios.hpp21
1 files changed, 17 insertions, 4 deletions
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