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