diff options
author | Tanous <ed.tanous@intel.com> | 2018-11-05 07:18:10 +0300 |
---|---|---|
committer | Ed Tanous <ed.tanous@intel.com> | 2019-04-01 20:01:41 +0300 |
commit | f00032db72e7ee88946bb4839b5d5311a3e092b3 (patch) | |
tree | 5bc236c459831bd33a5e8fcaeb60e74b966798a9 /include | |
parent | 20e6ea5dbfaa04f4298116281ddfb997847189ce (diff) | |
download | bmcweb-f00032db72e7ee88946bb4839b5d5311a3e092b3.tar.xz |
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 <ed.tanous@intel.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/http_utility.hpp | 2 | ||||
-rw-r--r-- | include/openbmc_dbus_rest.hpp | 29 |
2 files changed, 28 insertions, 3 deletions
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 <boost/algorithm/string.hpp> +#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 <typename... Middlewares> void requestRoutes(Crow<Middlewares...> &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 <typename... Middlewares> void requestRoutes(Crow<Middlewares...> &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 <typename... Middlewares> void requestRoutes(Crow<Middlewares...> &app) }); BMCWEB_ROUTE(app, "/list/") + .requires({"Login"}) .methods("GET"_method)( [](const crow::Request &req, crow::Response &res) { handleList(res, "/"); }); BMCWEB_ROUTE(app, "/xyz/<path>") - .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/<path>") + .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 <typename... Middlewares> void requestRoutes(Crow<Middlewares...> &app) }); BMCWEB_ROUTE(app, "/org/<path>") - .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/<path>") + .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/<str>/") + .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 <typename... Middlewares> void requestRoutes(Crow<Middlewares...> &app) }); BMCWEB_ROUTE(app, "/bus/system/<str>/") + .requires({"Login"}) .methods("GET"_method)([](const crow::Request &req, crow::Response &res, const std::string &Connection) { introspectObjects(Connection, "/", |