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