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