Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2018 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
| 16 | #pragma once |
Borawski.Lukasz | 43a095a | 2018-02-19 15:39:01 +0100 | [diff] [blame] | 17 | |
Kowalski, Kamil | f4c4dcf | 2018-01-29 14:55:35 +0100 | [diff] [blame] | 18 | #include "error_messages.hpp" |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 19 | #include "persistent_data.hpp" |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 20 | |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 21 | #include <app.hpp> |
Ed Tanous | ace85d6 | 2021-10-26 12:45:59 -0700 | [diff] [blame] | 22 | #include <http/utility.hpp> |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 23 | #include <query.hpp> |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 24 | #include <registries/privilege_registry.hpp> |
Ed Tanous | 840098b | 2022-06-28 12:06:17 -0700 | [diff] [blame] | 25 | #include <utils/json_utils.hpp> |
John Edward Broadbent | 7e860f1 | 2021-04-08 15:57:16 -0700 | [diff] [blame] | 26 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 27 | namespace redfish |
| 28 | { |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 29 | |
Ed Tanous | 4f48d5f | 2021-06-21 08:27:45 -0700 | [diff] [blame] | 30 | inline void fillSessionObject(crow::Response& res, |
| 31 | const persistent_data::UserSession& session) |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 32 | { |
Ed Tanous | faa34cc | 2021-06-03 13:27:02 -0700 | [diff] [blame] | 33 | res.jsonValue["Id"] = session.uniqueId; |
| 34 | res.jsonValue["UserName"] = session.username; |
| 35 | res.jsonValue["@odata.id"] = |
| 36 | "/redfish/v1/SessionService/Sessions/" + session.uniqueId; |
| 37 | res.jsonValue["@odata.type"] = "#Session.v1_3_0.Session"; |
| 38 | res.jsonValue["Name"] = "User Session"; |
| 39 | res.jsonValue["Description"] = "Manager User Session"; |
| 40 | res.jsonValue["ClientOriginIPAddress"] = session.clientIp; |
Sunitha Harish | c0ea7ae | 2020-10-30 02:37:30 -0500 | [diff] [blame] | 41 | #ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE |
Ed Tanous | faa34cc | 2021-06-03 13:27:02 -0700 | [diff] [blame] | 42 | res.jsonValue["Oem"]["OpenBMC"]["@odata.type"] = |
| 43 | "#OemSession.v1_0_0.Session"; |
| 44 | res.jsonValue["Oem"]["OpenBMC"]["ClientID"] = session.clientId; |
Sunitha Harish | 08bdcc7 | 2020-05-12 05:17:57 -0500 | [diff] [blame] | 45 | #endif |
Ed Tanous | faa34cc | 2021-06-03 13:27:02 -0700 | [diff] [blame] | 46 | } |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 47 | |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 48 | inline void |
Ed Tanous | a1e0871 | 2022-07-07 16:10:39 -0700 | [diff] [blame] | 49 | handleSessionHead(crow::App& app, const crow::Request& req, |
| 50 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 51 | const std::string& /*sessionId*/) |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 52 | { |
Ed Tanous | a1e0871 | 2022-07-07 16:10:39 -0700 | [diff] [blame] | 53 | |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 54 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 55 | { |
| 56 | return; |
| 57 | } |
Ed Tanous | a1e0871 | 2022-07-07 16:10:39 -0700 | [diff] [blame] | 58 | asyncResp->res.addHeader( |
| 59 | boost::beast::http::field::link, |
| 60 | "</redfish/v1/JsonSchemas/Session/Session.json>; rel=describedby"); |
| 61 | } |
| 62 | |
| 63 | inline void |
| 64 | handleSessionGet(crow::App& app, const crow::Request& req, |
| 65 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 66 | const std::string& sessionId) |
| 67 | { |
| 68 | handleSessionHead(app, req, asyncResp, sessionId); |
| 69 | |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 70 | // Note that control also reaches here via doPost and doDelete. |
| 71 | auto session = |
| 72 | persistent_data::SessionStore::getInstance().getSessionByUid(sessionId); |
| 73 | |
| 74 | if (session == nullptr) |
| 75 | { |
| 76 | messages::resourceNotFound(asyncResp->res, "Session", sessionId); |
| 77 | return; |
| 78 | } |
| 79 | |
| 80 | fillSessionObject(asyncResp->res, *session); |
| 81 | } |
| 82 | |
| 83 | inline void |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 84 | handleSessionDelete(crow::App& app, const crow::Request& req, |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 85 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, |
| 86 | const std::string& sessionId) |
| 87 | { |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 88 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 89 | { |
| 90 | return; |
| 91 | } |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 92 | auto session = |
| 93 | persistent_data::SessionStore::getInstance().getSessionByUid(sessionId); |
| 94 | |
| 95 | if (session == nullptr) |
| 96 | { |
| 97 | messages::resourceNotFound(asyncResp->res, "Session", sessionId); |
| 98 | return; |
| 99 | } |
| 100 | |
| 101 | // Perform a proper ConfigureSelf authority check. If a |
| 102 | // session is being used to DELETE some other user's session, |
| 103 | // then the ConfigureSelf privilege does not apply. In that |
| 104 | // case, perform the authority check again without the user's |
| 105 | // ConfigureSelf privilege. |
wukaihua-fii-na | 0fd2986 | 2022-05-18 09:19:16 +0800 | [diff] [blame] | 106 | if (req.session != nullptr && !session->username.empty() && |
| 107 | session->username != req.session->username) |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 108 | { |
| 109 | Privileges effectiveUserPrivileges = |
| 110 | redfish::getUserPrivileges(req.userRole); |
| 111 | |
| 112 | if (!effectiveUserPrivileges.isSupersetOf({"ConfigureUsers"})) |
| 113 | { |
| 114 | messages::insufficientPrivilege(asyncResp->res); |
| 115 | return; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | persistent_data::SessionStore::getInstance().removeSession(session); |
| 120 | messages::success(asyncResp->res); |
| 121 | } |
| 122 | |
| 123 | inline nlohmann::json getSessionCollectionMembers() |
| 124 | { |
| 125 | std::vector<const std::string*> sessionIds = |
| 126 | persistent_data::SessionStore::getInstance().getUniqueIds( |
| 127 | false, persistent_data::PersistenceType::TIMEOUT); |
| 128 | nlohmann::json ret = nlohmann::json::array(); |
| 129 | for (const std::string* uid : sessionIds) |
| 130 | { |
Ed Tanous | 1476687 | 2022-03-15 10:44:42 -0700 | [diff] [blame] | 131 | nlohmann::json::object_t session; |
| 132 | session["@odata.id"] = "/redfish/v1/SessionService/Sessions/" + *uid; |
| 133 | ret.push_back(std::move(session)); |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 134 | } |
| 135 | return ret; |
| 136 | } |
| 137 | |
Ed Tanous | a1e0871 | 2022-07-07 16:10:39 -0700 | [diff] [blame] | 138 | inline void handleSessionCollectionHead( |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 139 | crow::App& app, const crow::Request& req, |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 140 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) |
| 141 | { |
Ed Tanous | a1e0871 | 2022-07-07 16:10:39 -0700 | [diff] [blame] | 142 | |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 143 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 144 | { |
| 145 | return; |
| 146 | } |
Ed Tanous | a1e0871 | 2022-07-07 16:10:39 -0700 | [diff] [blame] | 147 | asyncResp->res.addHeader( |
| 148 | boost::beast::http::field::link, |
| 149 | "</redfish/v1/JsonSchemas/SessionCollection.json>; rel=describedby"); |
| 150 | } |
| 151 | |
| 152 | inline void handleSessionCollectionGet( |
| 153 | crow::App& app, const crow::Request& req, |
| 154 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) |
| 155 | { |
| 156 | handleSessionCollectionHead(app, req, asyncResp); |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 157 | asyncResp->res.jsonValue["Members"] = getSessionCollectionMembers(); |
| 158 | asyncResp->res.jsonValue["Members@odata.count"] = |
| 159 | asyncResp->res.jsonValue["Members"].size(); |
| 160 | asyncResp->res.jsonValue["@odata.type"] = |
| 161 | "#SessionCollection.SessionCollection"; |
| 162 | asyncResp->res.jsonValue["@odata.id"] = |
| 163 | "/redfish/v1/SessionService/Sessions/"; |
| 164 | asyncResp->res.jsonValue["Name"] = "Session Collection"; |
| 165 | asyncResp->res.jsonValue["Description"] = "Session Collection"; |
| 166 | } |
| 167 | |
| 168 | inline void handleSessionCollectionMembersGet( |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 169 | crow::App& app, const crow::Request& req, |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 170 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) |
| 171 | { |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 172 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 173 | { |
| 174 | return; |
| 175 | } |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 176 | asyncResp->res.jsonValue = getSessionCollectionMembers(); |
| 177 | } |
| 178 | |
Ed Tanous | 4ee8e21 | 2022-05-28 09:42:51 -0700 | [diff] [blame] | 179 | inline void handleSessionCollectionPost( |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 180 | crow::App& app, const crow::Request& req, |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 181 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) |
| 182 | { |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 183 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 184 | { |
| 185 | return; |
| 186 | } |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 187 | std::string username; |
| 188 | std::string password; |
| 189 | std::optional<nlohmann::json> oemObject; |
| 190 | std::string clientId; |
| 191 | if (!json_util::readJsonPatch(req, asyncResp->res, "UserName", username, |
| 192 | "Password", password, "Oem", oemObject)) |
| 193 | { |
| 194 | return; |
| 195 | } |
| 196 | |
| 197 | if (password.empty() || username.empty() || |
| 198 | asyncResp->res.result() != boost::beast::http::status::ok) |
| 199 | { |
| 200 | if (username.empty()) |
| 201 | { |
| 202 | messages::propertyMissing(asyncResp->res, "UserName"); |
| 203 | } |
| 204 | |
| 205 | if (password.empty()) |
| 206 | { |
| 207 | messages::propertyMissing(asyncResp->res, "Password"); |
| 208 | } |
| 209 | |
| 210 | return; |
| 211 | } |
| 212 | |
| 213 | int pamrc = pamAuthenticateUser(username, password); |
| 214 | bool isConfigureSelfOnly = pamrc == PAM_NEW_AUTHTOK_REQD; |
| 215 | if ((pamrc != PAM_SUCCESS) && !isConfigureSelfOnly) |
| 216 | { |
| 217 | messages::resourceAtUriUnauthorized(asyncResp->res, req.urlView, |
| 218 | "Invalid username or password"); |
| 219 | return; |
| 220 | } |
| 221 | #ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE |
| 222 | if (oemObject) |
| 223 | { |
| 224 | std::optional<nlohmann::json> bmcOem; |
| 225 | if (!json_util::readJson(*oemObject, asyncResp->res, "OpenBMC", bmcOem)) |
| 226 | { |
| 227 | return; |
| 228 | } |
| 229 | if (!json_util::readJson(*bmcOem, asyncResp->res, "ClientID", clientId)) |
| 230 | { |
| 231 | BMCWEB_LOG_ERROR << "Could not read ClientId"; |
| 232 | return; |
| 233 | } |
| 234 | } |
| 235 | #endif |
| 236 | |
| 237 | // User is authenticated - create session |
| 238 | std::shared_ptr<persistent_data::UserSession> session = |
| 239 | persistent_data::SessionStore::getInstance().generateUserSession( |
| 240 | username, req.ipAddress, clientId, |
| 241 | persistent_data::PersistenceType::TIMEOUT, isConfigureSelfOnly); |
Brad Bishop | 02e53ae | 2022-07-29 14:38:40 -0400 | [diff] [blame] | 242 | if (session == nullptr) |
| 243 | { |
| 244 | messages::internalError(asyncResp->res); |
| 245 | return; |
| 246 | } |
| 247 | |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 248 | asyncResp->res.addHeader("X-Auth-Token", session->sessionToken); |
| 249 | asyncResp->res.addHeader( |
| 250 | "Location", "/redfish/v1/SessionService/Sessions/" + session->uniqueId); |
| 251 | asyncResp->res.result(boost::beast::http::status::created); |
| 252 | if (session->isConfigureSelfOnly) |
| 253 | { |
| 254 | messages::passwordChangeRequired( |
| 255 | asyncResp->res, |
| 256 | crow::utility::urlFromPieces("redfish", "v1", "AccountService", |
Brad Bishop | 85e6471 | 2022-07-29 12:59:07 -0400 | [diff] [blame] | 257 | "Accounts", session->username)); |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | fillSessionObject(asyncResp->res, *session); |
| 261 | } |
Ed Tanous | a1e0871 | 2022-07-07 16:10:39 -0700 | [diff] [blame] | 262 | inline void handleSessionServiceHead( |
| 263 | crow::App& app, const crow::Request& req, |
| 264 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) |
| 265 | { |
| 266 | |
| 267 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
| 268 | { |
| 269 | return; |
| 270 | } |
| 271 | asyncResp->res.addHeader( |
| 272 | boost::beast::http::field::link, |
| 273 | "</redfish/v1/JsonSchemas/SessionService/SessionService.json>; rel=describedby"); |
| 274 | } |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 275 | inline void |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 276 | handleSessionServiceGet(crow::App& app, const crow::Request& req, |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 277 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) |
| 278 | |
| 279 | { |
Ed Tanous | a1e0871 | 2022-07-07 16:10:39 -0700 | [diff] [blame] | 280 | handleSessionServiceHead(app, req, asyncResp); |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 281 | asyncResp->res.jsonValue["@odata.type"] = |
| 282 | "#SessionService.v1_0_2.SessionService"; |
| 283 | asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/SessionService/"; |
| 284 | asyncResp->res.jsonValue["Name"] = "Session Service"; |
| 285 | asyncResp->res.jsonValue["Id"] = "SessionService"; |
| 286 | asyncResp->res.jsonValue["Description"] = "Session Service"; |
| 287 | asyncResp->res.jsonValue["SessionTimeout"] = |
| 288 | persistent_data::SessionStore::getInstance().getTimeoutInSeconds(); |
| 289 | asyncResp->res.jsonValue["ServiceEnabled"] = true; |
| 290 | |
Ed Tanous | 1476687 | 2022-03-15 10:44:42 -0700 | [diff] [blame] | 291 | asyncResp->res.jsonValue["Sessions"]["@odata.id"] = |
| 292 | "/redfish/v1/SessionService/Sessions"; |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | inline void handleSessionServicePatch( |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 296 | crow::App& app, const crow::Request& req, |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 297 | const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) |
| 298 | { |
Carson Labrado | 3ba0007 | 2022-06-06 19:40:56 +0000 | [diff] [blame] | 299 | if (!redfish::setUpRedfishRoute(app, req, asyncResp)) |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 300 | { |
| 301 | return; |
| 302 | } |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 303 | std::optional<int64_t> sessionTimeout; |
| 304 | if (!json_util::readJsonPatch(req, asyncResp->res, "SessionTimeout", |
| 305 | sessionTimeout)) |
| 306 | { |
| 307 | return; |
| 308 | } |
| 309 | |
| 310 | if (sessionTimeout) |
| 311 | { |
| 312 | // The mininum & maximum allowed values for session timeout |
| 313 | // are 30 seconds and 86400 seconds respectively as per the |
| 314 | // session service schema mentioned at |
| 315 | // https://redfish.dmtf.org/schemas/v1/SessionService.v1_1_7.json |
| 316 | |
| 317 | if (*sessionTimeout <= 86400 && *sessionTimeout >= 30) |
| 318 | { |
| 319 | std::chrono::seconds sessionTimeoutInseconds(*sessionTimeout); |
| 320 | persistent_data::SessionStore::getInstance().updateSessionTimeout( |
| 321 | sessionTimeoutInseconds); |
| 322 | messages::propertyValueModified(asyncResp->res, "SessionTimeOut", |
| 323 | std::to_string(*sessionTimeout)); |
| 324 | } |
| 325 | else |
| 326 | { |
| 327 | messages::propertyValueNotInList(asyncResp->res, |
| 328 | std::to_string(*sessionTimeout), |
| 329 | "SessionTimeOut"); |
| 330 | } |
| 331 | } |
| 332 | } |
| 333 | |
Ed Tanous | faa34cc | 2021-06-03 13:27:02 -0700 | [diff] [blame] | 334 | inline void requestRoutesSession(App& app) |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 335 | { |
Ed Tanous | faa34cc | 2021-06-03 13:27:02 -0700 | [diff] [blame] | 336 | BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/<str>/") |
Ed Tanous | a1e0871 | 2022-07-07 16:10:39 -0700 | [diff] [blame] | 337 | .privileges(redfish::privileges::headSession) |
| 338 | .methods(boost::beast::http::verb::head)( |
| 339 | std::bind_front(handleSessionHead, std::ref(app))); |
| 340 | |
| 341 | BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/<str>/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 342 | .privileges(redfish::privileges::getSession) |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 343 | .methods(boost::beast::http::verb::get)( |
| 344 | std::bind_front(handleSessionGet, std::ref(app))); |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 345 | |
Ed Tanous | faa34cc | 2021-06-03 13:27:02 -0700 | [diff] [blame] | 346 | BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/<str>/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 347 | .privileges(redfish::privileges::deleteSession) |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 348 | .methods(boost::beast::http::verb::delete_)( |
| 349 | std::bind_front(handleSessionDelete, std::ref(app))); |
Ed Tanous | faa34cc | 2021-06-03 13:27:02 -0700 | [diff] [blame] | 350 | |
| 351 | BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/") |
Ed Tanous | a1e0871 | 2022-07-07 16:10:39 -0700 | [diff] [blame] | 352 | .privileges(redfish::privileges::headSessionCollection) |
| 353 | .methods(boost::beast::http::verb::head)( |
| 354 | std::bind_front(handleSessionCollectionHead, std::ref(app))); |
| 355 | |
| 356 | BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 357 | .privileges(redfish::privileges::getSessionCollection) |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 358 | .methods(boost::beast::http::verb::get)( |
| 359 | std::bind_front(handleSessionCollectionGet, std::ref(app))); |
Ed Tanous | faa34cc | 2021-06-03 13:27:02 -0700 | [diff] [blame] | 360 | |
Ed Tanous | e76cd86 | 2022-03-14 09:12:00 -0700 | [diff] [blame] | 361 | // Note, the next two routes technically don't match the privilege |
Ed Tanous | 724340d | 2022-03-14 09:10:07 -0700 | [diff] [blame] | 362 | // registry given the way login mechanisms work. The base privilege |
| 363 | // registry lists this endpoint as requiring login privilege, but because |
| 364 | // this is the endpoint responsible for giving the login privilege, and it |
| 365 | // is itself its own route, it needs to not require Login |
Ed Tanous | faa34cc | 2021-06-03 13:27:02 -0700 | [diff] [blame] | 366 | BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/") |
| 367 | .privileges({}) |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 368 | .methods(boost::beast::http::verb::post)( |
| 369 | std::bind_front(handleSessionCollectionPost, std::ref(app))); |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 370 | |
Ed Tanous | e76cd86 | 2022-03-14 09:12:00 -0700 | [diff] [blame] | 371 | BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/Members/") |
| 372 | .privileges({}) |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 373 | .methods(boost::beast::http::verb::post)( |
| 374 | std::bind_front(handleSessionCollectionPost, std::ref(app))); |
Ed Tanous | e76cd86 | 2022-03-14 09:12:00 -0700 | [diff] [blame] | 375 | |
Ed Tanous | faa34cc | 2021-06-03 13:27:02 -0700 | [diff] [blame] | 376 | BMCWEB_ROUTE(app, "/redfish/v1/SessionService/") |
Ed Tanous | a1e0871 | 2022-07-07 16:10:39 -0700 | [diff] [blame] | 377 | .privileges(redfish::privileges::headSessionService) |
| 378 | .methods(boost::beast::http::verb::head)( |
| 379 | std::bind_front(handleSessionServiceHead, std::ref(app))); |
| 380 | |
| 381 | BMCWEB_ROUTE(app, "/redfish/v1/SessionService/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 382 | .privileges(redfish::privileges::getSessionService) |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 383 | .methods(boost::beast::http::verb::get)( |
| 384 | std::bind_front(handleSessionServiceGet, std::ref(app))); |
Borawski.Lukasz | 5d27b85 | 2018-02-08 13:24:24 +0100 | [diff] [blame] | 385 | |
Ed Tanous | faa34cc | 2021-06-03 13:27:02 -0700 | [diff] [blame] | 386 | BMCWEB_ROUTE(app, "/redfish/v1/SessionService/") |
Ed Tanous | ed39821 | 2021-06-09 17:05:54 -0700 | [diff] [blame] | 387 | .privileges(redfish::privileges::patchSessionService) |
Ed Tanous | 45ca1b8 | 2022-03-25 13:07:27 -0700 | [diff] [blame] | 388 | .methods(boost::beast::http::verb::patch)( |
| 389 | std::bind_front(handleSessionServicePatch, std::ref(app))); |
Ed Tanous | faa34cc | 2021-06-03 13:27:02 -0700 | [diff] [blame] | 390 | } |
Borawski.Lukasz | 5d27b85 | 2018-02-08 13:24:24 +0100 | [diff] [blame] | 391 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 392 | } // namespace redfish |