From f00032db72e7ee88946bb4839b5d5311a3e092b3 Mon Sep 17 00:00:00 2001 From: Tanous Date: Mon, 5 Nov 2018 01:18:10 -0300 Subject: Allow multiple registrations This patchset is the beginings of the infrastructure to allow separate registrations, and map privileges to the actual node in the url table rather than having each registration manage privileges manually. Tested by: Running redfish compliance tool. All things still pass. Change-Id: I72d278cc19c60ba5b6e563fbd705b0551faf9a6a Signed-off-by: Ed Tanous --- include/http_utility.hpp | 2 ++ include/openbmc_dbus_rest.hpp | 29 ++++++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/http_utility.hpp b/include/http_utility.hpp index e2b1a11f64..b20952b438 100644 --- a/include/http_utility.hpp +++ b/include/http_utility.hpp @@ -1,6 +1,8 @@ #pragma once #include +#include "crow/http_request.h" + namespace http_helpers { inline bool requestPrefersHtml(const crow::Request& req) diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp index ab35bb2efc..9f7a85508b 100644 --- a/include/openbmc_dbus_rest.hpp +++ b/include/openbmc_dbus_rest.hpp @@ -1982,6 +1982,7 @@ inline void handleDBusUrl(const crow::Request &req, crow::Response &res, template void requestRoutes(Crow &app) { BMCWEB_ROUTE(app, "/bus/") + .requires({"Login"}) .methods("GET"_method)( [](const crow::Request &req, crow::Response &res) { res.jsonValue = {{"busses", {{{"name", "system"}}}}, @@ -1990,6 +1991,7 @@ template void requestRoutes(Crow &app) }); BMCWEB_ROUTE(app, "/bus/system/") + .requires({"Login"}) .methods("GET"_method)( [](const crow::Request &req, crow::Response &res) { auto myCallback = [&res](const boost::system::error_code ec, @@ -2018,13 +2020,23 @@ template void requestRoutes(Crow &app) }); BMCWEB_ROUTE(app, "/list/") + .requires({"Login"}) .methods("GET"_method)( [](const crow::Request &req, crow::Response &res) { handleList(res, "/"); }); BMCWEB_ROUTE(app, "/xyz/") - .methods("GET"_method, "PUT"_method, "POST"_method, "DELETE"_method)( + .requires({"Login"}) + .methods("GET"_method)([](const crow::Request &req, crow::Response &res, + const std::string &path) { + std::string objectPath = "/xyz/" + path; + handleDBusUrl(req, res, objectPath); + }); + + BMCWEB_ROUTE(app, "/xyz/") + .requires({"ConfigureComponents", "ConfigureManager"}) + .methods("PUT"_method, "POST"_method, "DELETE"_method)( [](const crow::Request &req, crow::Response &res, const std::string &path) { std::string objectPath = "/xyz/" + path; @@ -2032,14 +2044,24 @@ template void requestRoutes(Crow &app) }); BMCWEB_ROUTE(app, "/org/") - .methods("GET"_method, "PUT"_method, "POST"_method, "DELETE"_method)( + .requires({"Login"}) + .methods("GET"_method)([](const crow::Request &req, crow::Response &res, + const std::string &path) { + std::string objectPath = "/xyz/" + path; + handleDBusUrl(req, res, objectPath); + }); + + BMCWEB_ROUTE(app, "/org/") + .requires({"ConfigureComponents", "ConfigureManager"}) + .methods("PUT"_method, "POST"_method, "DELETE"_method)( [](const crow::Request &req, crow::Response &res, const std::string &path) { - std::string objectPath = "/org/" + path; + std::string objectPath = "/xyz/" + path; handleDBusUrl(req, res, objectPath); }); BMCWEB_ROUTE(app, "/download/dump//") + .requires({"ConfigureManager"}) .methods("GET"_method)([](const crow::Request &req, crow::Response &res, const std::string &dumpId) { std::regex validFilename("^[\\w\\- ]+(\\.?[\\w\\- ]*)$"); @@ -2083,6 +2105,7 @@ template void requestRoutes(Crow &app) }); BMCWEB_ROUTE(app, "/bus/system//") + .requires({"Login"}) .methods("GET"_method)([](const crow::Request &req, crow::Response &res, const std::string &Connection) { introspectObjects(Connection, "/", -- cgit v1.2.3