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" |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 19 | #include "node.hpp" |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 20 | #include "persistent_data.hpp" |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 21 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 22 | namespace redfish |
| 23 | { |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 24 | |
| 25 | class SessionCollection; |
| 26 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 27 | class Sessions : public Node |
| 28 | { |
| 29 | public: |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 30 | Sessions(App& app) : |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 31 | Node(app, "/redfish/v1/SessionService/Sessions/<str>/", std::string()) |
| 32 | { |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 33 | entityPrivileges = { |
| 34 | {boost::beast::http::verb::get, {{"Login"}}}, |
| 35 | {boost::beast::http::verb::head, {{"Login"}}}, |
| 36 | {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, |
| 37 | {boost::beast::http::verb::put, {{"ConfigureManager"}}}, |
Joseph Reynolds | 900f949 | 2019-11-25 15:37:29 -0600 | [diff] [blame] | 38 | {boost::beast::http::verb::delete_, |
| 39 | {{"ConfigureManager"}, {"ConfigureSelf"}}}, |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 40 | {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 41 | } |
| 42 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 43 | private: |
Ed Tanous | cb13a39 | 2020-07-25 19:02:03 +0000 | [diff] [blame] | 44 | void doGet(crow::Response& res, const crow::Request&, |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 45 | const std::vector<std::string>& params) override |
| 46 | { |
Joseph Reynolds | 900f949 | 2019-11-25 15:37:29 -0600 | [diff] [blame] | 47 | // Note that control also reaches here via doPost and doDelete. |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 48 | auto session = |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 49 | persistent_data::SessionStore::getInstance().getSessionByUid( |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 50 | params[0]); |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 51 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 52 | if (session == nullptr) |
| 53 | { |
Jason M. Bills | f12894f | 2018-10-09 12:45:45 -0700 | [diff] [blame] | 54 | messages::resourceNotFound(res, "Session", params[0]); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 55 | res.end(); |
| 56 | return; |
| 57 | } |
Kowalski, Kamil | f4c4dcf | 2018-01-29 14:55:35 +0100 | [diff] [blame] | 58 | |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 59 | res.jsonValue["Id"] = session->uniqueId; |
| 60 | res.jsonValue["UserName"] = session->username; |
| 61 | res.jsonValue["@odata.id"] = |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 62 | "/redfish/v1/SessionService/Sessions/" + session->uniqueId; |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 63 | res.jsonValue["@odata.type"] = "#Session.v1_0_2.Session"; |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 64 | res.jsonValue["Name"] = "User Session"; |
| 65 | res.jsonValue["Description"] = "Manager User Session"; |
Sunitha Harish | 08bdcc7 | 2020-05-12 05:17:57 -0500 | [diff] [blame] | 66 | res.jsonValue["Oem"]["OpenBMC"]["@odata.type"] = |
| 67 | "#OemSession.v1_0_0.Session"; |
Sunitha Harish | 92f6822 | 2020-05-28 05:09:09 -0500 | [diff] [blame] | 68 | #ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE |
Sunitha Harish | 08bdcc7 | 2020-05-12 05:17:57 -0500 | [diff] [blame] | 69 | res.jsonValue["Oem"]["OpenBMC"]["ClientID"] = session->clientId; |
| 70 | #endif |
Sunitha Harish | 92f6822 | 2020-05-28 05:09:09 -0500 | [diff] [blame] | 71 | res.jsonValue["Oem"]["OpenBMC"]["ClientOriginIP"] = session->clientIp; |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 72 | res.end(); |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 73 | } |
| 74 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 75 | void doDelete(crow::Response& res, const crow::Request& req, |
| 76 | const std::vector<std::string>& params) override |
| 77 | { |
| 78 | // Need only 1 param which should be id of session to be deleted |
| 79 | if (params.size() != 1) |
| 80 | { |
| 81 | // This should be handled by crow and never happen |
| 82 | BMCWEB_LOG_ERROR << "Session DELETE has been called with invalid " |
| 83 | "number of params"; |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 84 | |
Jason M. Bills | f12894f | 2018-10-09 12:45:45 -0700 | [diff] [blame] | 85 | messages::generalError(res); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 86 | res.end(); |
| 87 | return; |
| 88 | } |
| 89 | |
| 90 | auto session = |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 91 | persistent_data::SessionStore::getInstance().getSessionByUid( |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 92 | params[0]); |
| 93 | |
| 94 | if (session == nullptr) |
| 95 | { |
Jason M. Bills | f12894f | 2018-10-09 12:45:45 -0700 | [diff] [blame] | 96 | messages::resourceNotFound(res, "Session", params[0]); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 97 | res.end(); |
| 98 | return; |
| 99 | } |
| 100 | |
Joseph Reynolds | 900f949 | 2019-11-25 15:37:29 -0600 | [diff] [blame] | 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. |
| 106 | if (session->username != req.session->username) |
| 107 | { |
| 108 | if (!isAllowedWithoutConfigureSelf(req)) |
| 109 | { |
| 110 | BMCWEB_LOG_WARNING << "DELETE Session denied access"; |
| 111 | messages::insufficientPrivilege(res); |
| 112 | res.end(); |
| 113 | return; |
| 114 | } |
| 115 | } |
| 116 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 117 | // DELETE should return representation of object that will be removed |
| 118 | doGet(res, req, params); |
| 119 | |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 120 | persistent_data::SessionStore::getInstance().removeSession(session); |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 121 | } |
| 122 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 123 | /** |
| 124 | * This allows SessionCollection to reuse this class' doGet method, to |
| 125 | * maintain consistency of returned data, as Collection's doPost should |
Sunitha Harish | 92f6822 | 2020-05-28 05:09:09 -0500 | [diff] [blame] | 126 | * return data for created member which should match member's doGet |
| 127 | * result in 100% |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 128 | */ |
| 129 | friend SessionCollection; |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 130 | }; |
| 131 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 132 | class SessionCollection : public Node |
| 133 | { |
| 134 | public: |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 135 | SessionCollection(App& app) : |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 136 | Node(app, "/redfish/v1/SessionService/Sessions/"), memberSession(app) |
| 137 | { |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 138 | entityPrivileges = { |
| 139 | {boost::beast::http::verb::get, {{"Login"}}}, |
| 140 | {boost::beast::http::verb::head, {{"Login"}}}, |
| 141 | {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, |
| 142 | {boost::beast::http::verb::put, {{"ConfigureManager"}}}, |
| 143 | {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, |
| 144 | {boost::beast::http::verb::post, {}}}; |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 145 | } |
| 146 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 147 | private: |
Ed Tanous | cb13a39 | 2020-07-25 19:02:03 +0000 | [diff] [blame] | 148 | void doGet(crow::Response& res, const crow::Request&, |
| 149 | const std::vector<std::string>&) override |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 150 | { |
| 151 | std::vector<const std::string*> sessionIds = |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 152 | persistent_data::SessionStore::getInstance().getUniqueIds( |
| 153 | false, persistent_data::PersistenceType::TIMEOUT); |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 154 | |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 155 | res.jsonValue["Members@odata.count"] = sessionIds.size(); |
| 156 | res.jsonValue["Members"] = nlohmann::json::array(); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 157 | for (const std::string* uid : sessionIds) |
| 158 | { |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 159 | res.jsonValue["Members"].push_back( |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 160 | {{"@odata.id", "/redfish/v1/SessionService/Sessions/" + *uid}}); |
| 161 | } |
Tanous | f00032d | 2018-11-05 01:18:10 -0300 | [diff] [blame] | 162 | res.jsonValue["Members@odata.count"] = sessionIds.size(); |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 163 | res.jsonValue["@odata.type"] = "#SessionCollection.SessionCollection"; |
| 164 | res.jsonValue["@odata.id"] = "/redfish/v1/SessionService/Sessions/"; |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 165 | res.jsonValue["Name"] = "Session Collection"; |
| 166 | res.jsonValue["Description"] = "Session Collection"; |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 167 | res.end(); |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 168 | } |
| 169 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 170 | void doPost(crow::Response& res, const crow::Request& req, |
Ed Tanous | cb13a39 | 2020-07-25 19:02:03 +0000 | [diff] [blame] | 171 | const std::vector<std::string>&) override |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 172 | { |
Ed Tanous | 9712f8a | 2018-09-21 13:38:49 -0700 | [diff] [blame] | 173 | std::string username; |
| 174 | std::string password; |
Sunitha Harish | 08bdcc7 | 2020-05-12 05:17:57 -0500 | [diff] [blame] | 175 | std::optional<nlohmann::json> oemObject; |
| 176 | std::string clientId; |
Sunitha Harish | 92f6822 | 2020-05-28 05:09:09 -0500 | [diff] [blame] | 177 | std::string clientIp; |
Ed Tanous | 9712f8a | 2018-09-21 13:38:49 -0700 | [diff] [blame] | 178 | if (!json_util::readJson(req, res, "UserName", username, "Password", |
Sunitha Harish | 08bdcc7 | 2020-05-12 05:17:57 -0500 | [diff] [blame] | 179 | password, "Oem", oemObject)) |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 180 | { |
| 181 | res.end(); |
| 182 | return; |
| 183 | } |
Ed Tanous | b9845d9 | 2018-07-24 14:38:06 -0700 | [diff] [blame] | 184 | |
Ed Tanous | 820ce59 | 2018-10-04 15:54:21 -0700 | [diff] [blame] | 185 | if (password.empty() || username.empty() || |
| 186 | res.result() != boost::beast::http::status::ok) |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 187 | { |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 188 | if (username.empty()) |
| 189 | { |
Jason M. Bills | a08b46c | 2018-11-06 15:01:08 -0800 | [diff] [blame] | 190 | messages::propertyMissing(res, "UserName"); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | if (password.empty()) |
| 194 | { |
Jason M. Bills | a08b46c | 2018-11-06 15:01:08 -0800 | [diff] [blame] | 195 | messages::propertyMissing(res, "Password"); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 196 | } |
Ed Tanous | 820ce59 | 2018-10-04 15:54:21 -0700 | [diff] [blame] | 197 | res.end(); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 198 | |
Ed Tanous | 820ce59 | 2018-10-04 15:54:21 -0700 | [diff] [blame] | 199 | return; |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Joseph Reynolds | 3bf4e63 | 2020-02-06 14:44:32 -0600 | [diff] [blame] | 202 | int pamrc = pamAuthenticateUser(username, password); |
| 203 | bool isConfigureSelfOnly = pamrc == PAM_NEW_AUTHTOK_REQD; |
| 204 | if ((pamrc != PAM_SUCCESS) && !isConfigureSelfOnly) |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 205 | { |
Jason M. Bills | f12894f | 2018-10-09 12:45:45 -0700 | [diff] [blame] | 206 | messages::resourceAtUriUnauthorized(res, std::string(req.url), |
| 207 | "Invalid username or password"); |
Ed Tanous | 820ce59 | 2018-10-04 15:54:21 -0700 | [diff] [blame] | 208 | res.end(); |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 209 | |
Ed Tanous | 820ce59 | 2018-10-04 15:54:21 -0700 | [diff] [blame] | 210 | return; |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 211 | } |
Sunitha Harish | 08bdcc7 | 2020-05-12 05:17:57 -0500 | [diff] [blame] | 212 | #ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE |
| 213 | if (oemObject) |
| 214 | { |
| 215 | std::optional<nlohmann::json> bmcOem; |
| 216 | if (!json_util::readJson(*oemObject, res, "OpenBMC", bmcOem)) |
| 217 | { |
| 218 | res.end(); |
| 219 | return; |
| 220 | } |
| 221 | if (!json_util::readJson(*bmcOem, res, "ClientID", clientId)) |
| 222 | { |
| 223 | BMCWEB_LOG_ERROR << "Could not read ClientId"; |
| 224 | res.end(); |
| 225 | return; |
| 226 | } |
| 227 | } |
| 228 | #endif |
Manojkiran Eda | 6f115bb | 2020-06-27 09:52:23 +0530 | [diff] [blame] | 229 | |
Ed Tanous | 820ce59 | 2018-10-04 15:54:21 -0700 | [diff] [blame] | 230 | // User is authenticated - create session |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 231 | std::shared_ptr<persistent_data::UserSession> session = |
| 232 | persistent_data::SessionStore::getInstance().generateUserSession( |
| 233 | username, persistent_data::PersistenceType::TIMEOUT, |
| 234 | isConfigureSelfOnly, clientId, clientIp); |
Ed Tanous | 820ce59 | 2018-10-04 15:54:21 -0700 | [diff] [blame] | 235 | res.addHeader("X-Auth-Token", session->sessionToken); |
| 236 | res.addHeader("Location", "/redfish/v1/SessionService/Sessions/" + |
| 237 | session->uniqueId); |
| 238 | res.result(boost::beast::http::status::created); |
Joseph Reynolds | 3bf4e63 | 2020-02-06 14:44:32 -0600 | [diff] [blame] | 239 | if (session->isConfigureSelfOnly) |
| 240 | { |
| 241 | messages::passwordChangeRequired( |
| 242 | res, |
| 243 | "/redfish/v1/AccountService/Accounts/" + session->username); |
| 244 | } |
Ed Tanous | 820ce59 | 2018-10-04 15:54:21 -0700 | [diff] [blame] | 245 | memberSession.doGet(res, req, {session->uniqueId}); |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 246 | } |
| 247 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 248 | /** |
| 249 | * Member session to ensure consistency between collection's doPost and |
| 250 | * member's doGet, as they should return 100% matching data |
| 251 | */ |
| 252 | Sessions memberSession; |
Kowalski, Kamil | 2b7981f | 2018-01-31 13:24:59 +0100 | [diff] [blame] | 253 | }; |
| 254 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 255 | class SessionService : public Node |
| 256 | { |
| 257 | public: |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 258 | SessionService(App& app) : Node(app, "/redfish/v1/SessionService/") |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 259 | { |
Ed Tanous | 3ebd75f | 2018-03-05 18:20:01 -0800 | [diff] [blame] | 260 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 261 | entityPrivileges = { |
| 262 | {boost::beast::http::verb::get, {{"Login"}}}, |
| 263 | {boost::beast::http::verb::head, {{"Login"}}}, |
| 264 | {boost::beast::http::verb::patch, {{"ConfigureManager"}}}, |
| 265 | {boost::beast::http::verb::put, {{"ConfigureManager"}}}, |
| 266 | {boost::beast::http::verb::delete_, {{"ConfigureManager"}}}, |
| 267 | {boost::beast::http::verb::post, {{"ConfigureManager"}}}}; |
| 268 | } |
Borawski.Lukasz | 5d27b85 | 2018-02-08 13:24:24 +0100 | [diff] [blame] | 269 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 270 | private: |
Ed Tanous | cb13a39 | 2020-07-25 19:02:03 +0000 | [diff] [blame] | 271 | void doGet(crow::Response& res, const crow::Request&, |
| 272 | const std::vector<std::string>&) override |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 273 | { |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 274 | res.jsonValue["@odata.type"] = "#SessionService.v1_0_2.SessionService"; |
| 275 | res.jsonValue["@odata.id"] = "/redfish/v1/SessionService/"; |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 276 | res.jsonValue["Name"] = "Session Service"; |
| 277 | res.jsonValue["Id"] = "SessionService"; |
| 278 | res.jsonValue["Description"] = "Session Service"; |
| 279 | res.jsonValue["SessionTimeout"] = |
Ed Tanous | 52cc112 | 2020-07-18 13:51:21 -0700 | [diff] [blame] | 280 | persistent_data::SessionStore::getInstance().getTimeoutInSeconds(); |
Ed Tanous | 0f74e64 | 2018-11-12 15:17:05 -0800 | [diff] [blame] | 281 | res.jsonValue["ServiceEnabled"] = true; |
| 282 | |
Ed Tanous | 0f26153 | 2019-02-08 11:13:29 -0800 | [diff] [blame] | 283 | res.jsonValue["Sessions"] = { |
| 284 | {"@odata.id", "/redfish/v1/SessionService/Sessions"}}; |
| 285 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 286 | res.end(); |
| 287 | } |
Borawski.Lukasz | 5d27b85 | 2018-02-08 13:24:24 +0100 | [diff] [blame] | 288 | }; |
| 289 | |
Ed Tanous | 1abe55e | 2018-09-05 08:30:59 -0700 | [diff] [blame] | 290 | } // namespace redfish |