xref: /openbmc/bmcweb/features/redfish/lib/redfish_sessions.hpp (revision 3e72c2027aa4e64b9892ab0d3970358ba446f1fa)
12b7981f6SKowalski, Kamil /*
22b7981f6SKowalski, Kamil // Copyright (c) 2018 Intel Corporation
32b7981f6SKowalski, Kamil //
42b7981f6SKowalski, Kamil // Licensed under the Apache License, Version 2.0 (the "License");
52b7981f6SKowalski, Kamil // you may not use this file except in compliance with the License.
62b7981f6SKowalski, Kamil // You may obtain a copy of the License at
72b7981f6SKowalski, Kamil //
82b7981f6SKowalski, Kamil //      http://www.apache.org/licenses/LICENSE-2.0
92b7981f6SKowalski, Kamil //
102b7981f6SKowalski, Kamil // Unless required by applicable law or agreed to in writing, software
112b7981f6SKowalski, Kamil // distributed under the License is distributed on an "AS IS" BASIS,
122b7981f6SKowalski, Kamil // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
132b7981f6SKowalski, Kamil // See the License for the specific language governing permissions and
142b7981f6SKowalski, Kamil // limitations under the License.
152b7981f6SKowalski, Kamil */
162b7981f6SKowalski, Kamil #pragma once
1743a095abSBorawski.Lukasz 
183ccb3adbSEd Tanous #include "app.hpp"
19f4c4dcf4SKowalski, Kamil #include "error_messages.hpp"
203ccb3adbSEd Tanous #include "http/utility.hpp"
2152cc112dSEd Tanous #include "persistent_data.hpp"
223ccb3adbSEd Tanous #include "query.hpp"
233ccb3adbSEd Tanous #include "registries/privilege_registry.hpp"
243ccb3adbSEd Tanous #include "utils/json_utils.hpp"
257e860f15SJohn Edward Broadbent 
26ef4c65b7SEd Tanous #include <boost/url/format.hpp>
27ef4c65b7SEd Tanous 
281abe55efSEd Tanous namespace redfish
291abe55efSEd Tanous {
302b7981f6SKowalski, Kamil 
314f48d5f6SEd Tanous inline void fillSessionObject(crow::Response& res,
32faa34ccfSEd Tanous                               const persistent_data::UserSession& session)
331abe55efSEd Tanous {
34faa34ccfSEd Tanous     res.jsonValue["Id"] = session.uniqueId;
35faa34ccfSEd Tanous     res.jsonValue["UserName"] = session.username;
36ef4c65b7SEd Tanous     res.jsonValue["@odata.id"] = boost::urls::format(
37ef4c65b7SEd Tanous         "/redfish/v1/SessionService/Sessions/{}", session.uniqueId);
38bb759e3aSEd Tanous     res.jsonValue["@odata.type"] = "#Session.v1_5_0.Session";
39faa34ccfSEd Tanous     res.jsonValue["Name"] = "User Session";
40faa34ccfSEd Tanous     res.jsonValue["Description"] = "Manager User Session";
41faa34ccfSEd Tanous     res.jsonValue["ClientOriginIPAddress"] = session.clientIp;
42bb759e3aSEd Tanous     if (session.clientId)
43bb759e3aSEd Tanous     {
44bb759e3aSEd Tanous         res.jsonValue["Context"] = *session.clientId;
45bb759e3aSEd Tanous     }
462b7981f6SKowalski, Kamil }
472b7981f6SKowalski, Kamil 
48724340d7SEd Tanous inline void
49a1e0871dSEd Tanous     handleSessionHead(crow::App& app, const crow::Request& req,
50faa34ccfSEd Tanous                       const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
51a1e0871dSEd Tanous                       const std::string& /*sessionId*/)
52724340d7SEd Tanous {
533ba00073SCarson Labrado     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
5445ca1b86SEd Tanous     {
5545ca1b86SEd Tanous         return;
5645ca1b86SEd Tanous     }
57a1e0871dSEd Tanous     asyncResp->res.addHeader(
58a1e0871dSEd Tanous         boost::beast::http::field::link,
59a1e0871dSEd Tanous         "</redfish/v1/JsonSchemas/Session/Session.json>; rel=describedby");
60a1e0871dSEd Tanous }
61a1e0871dSEd Tanous 
62a1e0871dSEd Tanous inline void
63a1e0871dSEd Tanous     handleSessionGet(crow::App& app, const crow::Request& req,
64a1e0871dSEd Tanous                      const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
65a1e0871dSEd Tanous                      const std::string& sessionId)
66a1e0871dSEd Tanous {
6765ffbcb3SEd Tanous     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
6865ffbcb3SEd Tanous     {
6965ffbcb3SEd Tanous         return;
7065ffbcb3SEd Tanous     }
7165ffbcb3SEd Tanous     asyncResp->res.addHeader(
7265ffbcb3SEd Tanous         boost::beast::http::field::link,
7365ffbcb3SEd Tanous         "</redfish/v1/JsonSchemas/Session/Session.json>; rel=describedby");
74a1e0871dSEd Tanous 
75faa34ccfSEd Tanous     // Note that control also reaches here via doPost and doDelete.
76724340d7SEd Tanous     auto session =
77724340d7SEd Tanous         persistent_data::SessionStore::getInstance().getSessionByUid(sessionId);
782b7981f6SKowalski, Kamil 
791abe55efSEd Tanous     if (session == nullptr)
801abe55efSEd Tanous     {
81724340d7SEd Tanous         messages::resourceNotFound(asyncResp->res, "Session", sessionId);
82faa34ccfSEd Tanous         return;
83faa34ccfSEd Tanous     }
84faa34ccfSEd Tanous 
85faa34ccfSEd Tanous     fillSessionObject(asyncResp->res, *session);
86724340d7SEd Tanous }
87faa34ccfSEd Tanous 
88724340d7SEd Tanous inline void
8945ca1b86SEd Tanous     handleSessionDelete(crow::App& app, const crow::Request& req,
90faa34ccfSEd Tanous                         const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
91724340d7SEd Tanous                         const std::string& sessionId)
92724340d7SEd Tanous {
933ba00073SCarson Labrado     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
9445ca1b86SEd Tanous     {
9545ca1b86SEd Tanous         return;
9645ca1b86SEd Tanous     }
97724340d7SEd Tanous     auto session =
98724340d7SEd Tanous         persistent_data::SessionStore::getInstance().getSessionByUid(sessionId);
99faa34ccfSEd Tanous 
100faa34ccfSEd Tanous     if (session == nullptr)
101faa34ccfSEd Tanous     {
102724340d7SEd Tanous         messages::resourceNotFound(asyncResp->res, "Session", sessionId);
1032b7981f6SKowalski, Kamil         return;
1042b7981f6SKowalski, Kamil     }
1052b7981f6SKowalski, Kamil 
106900f9497SJoseph Reynolds     // Perform a proper ConfigureSelf authority check.  If a
107900f9497SJoseph Reynolds     // session is being used to DELETE some other user's session,
108900f9497SJoseph Reynolds     // then the ConfigureSelf privilege does not apply.  In that
109900f9497SJoseph Reynolds     // case, perform the authority check again without the user's
110900f9497SJoseph Reynolds     // ConfigureSelf privilege.
1110fd29865Swukaihua-fii-na     if (req.session != nullptr && !session->username.empty() &&
1120fd29865Swukaihua-fii-na         session->username != req.session->username)
113900f9497SJoseph Reynolds     {
1146c51eab1SEd Tanous         Privileges effectiveUserPrivileges =
115*3e72c202SNinad Palsule             redfish::getUserPrivileges(*req.session);
1166c51eab1SEd Tanous 
117724340d7SEd Tanous         if (!effectiveUserPrivileges.isSupersetOf({"ConfigureUsers"}))
118900f9497SJoseph Reynolds         {
1198d1b46d7Szhanghch05             messages::insufficientPrivilege(asyncResp->res);
120900f9497SJoseph Reynolds             return;
121900f9497SJoseph Reynolds         }
122900f9497SJoseph Reynolds     }
123900f9497SJoseph Reynolds 
124724340d7SEd Tanous     persistent_data::SessionStore::getInstance().removeSession(session);
1255cc148afSEd Tanous     messages::success(asyncResp->res);
126724340d7SEd Tanous }
127f4c4dcf4SKowalski, Kamil 
128724340d7SEd Tanous inline nlohmann::json getSessionCollectionMembers()
129724340d7SEd Tanous {
13055c7b7a2SEd Tanous     std::vector<const std::string*> sessionIds =
13152cc112dSEd Tanous         persistent_data::SessionStore::getInstance().getUniqueIds(
13252cc112dSEd Tanous             false, persistent_data::PersistenceType::TIMEOUT);
133724340d7SEd Tanous     nlohmann::json ret = nlohmann::json::array();
1341abe55efSEd Tanous     for (const std::string* uid : sessionIds)
1351abe55efSEd Tanous     {
1361476687dSEd Tanous         nlohmann::json::object_t session;
137ef4c65b7SEd Tanous         session["@odata.id"] =
138ef4c65b7SEd Tanous             boost::urls::format("/redfish/v1/SessionService/Sessions/{}", *uid);
139b2ba3072SPatrick Williams         ret.emplace_back(std::move(session));
1402b7981f6SKowalski, Kamil     }
141724340d7SEd Tanous     return ret;
142724340d7SEd Tanous }
143724340d7SEd Tanous 
144a1e0871dSEd Tanous inline void handleSessionCollectionHead(
14545ca1b86SEd Tanous     crow::App& app, const crow::Request& req,
146724340d7SEd Tanous     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
147724340d7SEd Tanous {
1483ba00073SCarson Labrado     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
14945ca1b86SEd Tanous     {
15045ca1b86SEd Tanous         return;
15145ca1b86SEd Tanous     }
152a1e0871dSEd Tanous     asyncResp->res.addHeader(
153a1e0871dSEd Tanous         boost::beast::http::field::link,
154a1e0871dSEd Tanous         "</redfish/v1/JsonSchemas/SessionCollection.json>; rel=describedby");
155a1e0871dSEd Tanous }
156a1e0871dSEd Tanous 
157a1e0871dSEd Tanous inline void handleSessionCollectionGet(
158a1e0871dSEd Tanous     crow::App& app, const crow::Request& req,
159a1e0871dSEd Tanous     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
160a1e0871dSEd Tanous {
161a1e0871dSEd Tanous     handleSessionCollectionHead(app, req, asyncResp);
162724340d7SEd Tanous     asyncResp->res.jsonValue["Members"] = getSessionCollectionMembers();
163faa34ccfSEd Tanous     asyncResp->res.jsonValue["Members@odata.count"] =
164724340d7SEd Tanous         asyncResp->res.jsonValue["Members"].size();
1658d1b46d7Szhanghch05     asyncResp->res.jsonValue["@odata.type"] =
1668d1b46d7Szhanghch05         "#SessionCollection.SessionCollection";
1678d1b46d7Szhanghch05     asyncResp->res.jsonValue["@odata.id"] =
1688d1b46d7Szhanghch05         "/redfish/v1/SessionService/Sessions/";
1698d1b46d7Szhanghch05     asyncResp->res.jsonValue["Name"] = "Session Collection";
1708d1b46d7Szhanghch05     asyncResp->res.jsonValue["Description"] = "Session Collection";
171724340d7SEd Tanous }
1722b7981f6SKowalski, Kamil 
173724340d7SEd Tanous inline void handleSessionCollectionMembersGet(
17445ca1b86SEd Tanous     crow::App& app, const crow::Request& req,
175724340d7SEd Tanous     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
176724340d7SEd Tanous {
1773ba00073SCarson Labrado     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
17845ca1b86SEd Tanous     {
17945ca1b86SEd Tanous         return;
18045ca1b86SEd Tanous     }
181724340d7SEd Tanous     asyncResp->res.jsonValue = getSessionCollectionMembers();
182724340d7SEd Tanous }
183724340d7SEd Tanous 
1844ee8e211SEd Tanous inline void handleSessionCollectionPost(
18545ca1b86SEd Tanous     crow::App& app, const crow::Request& req,
186724340d7SEd Tanous     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
187724340d7SEd Tanous {
1883ba00073SCarson Labrado     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
18945ca1b86SEd Tanous     {
19045ca1b86SEd Tanous         return;
19145ca1b86SEd Tanous     }
1929712f8acSEd Tanous     std::string username;
1939712f8acSEd Tanous     std::string password;
194bb759e3aSEd Tanous     std::optional<std::string> clientId;
195724340d7SEd Tanous     if (!json_util::readJsonPatch(req, asyncResp->res, "UserName", username,
196d678d4fcSEd Tanous                                   "Password", password, "Context", clientId))
1971abe55efSEd Tanous     {
1982b7981f6SKowalski, Kamil         return;
1992b7981f6SKowalski, Kamil     }
2002b7981f6SKowalski, Kamil 
201820ce598SEd Tanous     if (password.empty() || username.empty() ||
2028d1b46d7Szhanghch05         asyncResp->res.result() != boost::beast::http::status::ok)
2031abe55efSEd Tanous     {
2041abe55efSEd Tanous         if (username.empty())
2051abe55efSEd Tanous         {
2068d1b46d7Szhanghch05             messages::propertyMissing(asyncResp->res, "UserName");
207f4c4dcf4SKowalski, Kamil         }
208f4c4dcf4SKowalski, Kamil 
2091abe55efSEd Tanous         if (password.empty())
2101abe55efSEd Tanous         {
2118d1b46d7Szhanghch05             messages::propertyMissing(asyncResp->res, "Password");
212820ce598SEd Tanous         }
213820ce598SEd Tanous 
214820ce598SEd Tanous         return;
215f4c4dcf4SKowalski, Kamil     }
2162b7981f6SKowalski, Kamil 
2173bf4e632SJoseph Reynolds     int pamrc = pamAuthenticateUser(username, password);
2183bf4e632SJoseph Reynolds     bool isConfigureSelfOnly = pamrc == PAM_NEW_AUTHTOK_REQD;
2193bf4e632SJoseph Reynolds     if ((pamrc != PAM_SUCCESS) && !isConfigureSelfOnly)
2201abe55efSEd Tanous     {
22139662a3bSEd Tanous         messages::resourceAtUriUnauthorized(asyncResp->res, req.url(),
222f12894f8SJason M. Bills                                             "Invalid username or password");
223820ce598SEd Tanous         return;
2242b7981f6SKowalski, Kamil     }
2256f115bbbSManojkiran Eda 
226820ce598SEd Tanous     // User is authenticated - create session
22752cc112dSEd Tanous     std::shared_ptr<persistent_data::UserSession> session =
228724340d7SEd Tanous         persistent_data::SessionStore::getInstance().generateUserSession(
22941d61c82SJiaqing Zhao             username, req.ipAddress, clientId,
230724340d7SEd Tanous             persistent_data::PersistenceType::TIMEOUT, isConfigureSelfOnly);
23102e53aefSBrad Bishop     if (session == nullptr)
23202e53aefSBrad Bishop     {
23302e53aefSBrad Bishop         messages::internalError(asyncResp->res);
23402e53aefSBrad Bishop         return;
23502e53aefSBrad Bishop     }
23602e53aefSBrad Bishop 
2378d1b46d7Szhanghch05     asyncResp->res.addHeader("X-Auth-Token", session->sessionToken);
238faa34ccfSEd Tanous     asyncResp->res.addHeader(
239724340d7SEd Tanous         "Location", "/redfish/v1/SessionService/Sessions/" + session->uniqueId);
2408d1b46d7Szhanghch05     asyncResp->res.result(boost::beast::http::status::created);
2413bf4e632SJoseph Reynolds     if (session->isConfigureSelfOnly)
2423bf4e632SJoseph Reynolds     {
2433bf4e632SJoseph Reynolds         messages::passwordChangeRequired(
244724340d7SEd Tanous             asyncResp->res,
245ef4c65b7SEd Tanous             boost::urls::format("/redfish/v1/AccountService/Accounts/{}",
246ef4c65b7SEd Tanous                                 session->username));
2472b7981f6SKowalski, Kamil     }
2482b7981f6SKowalski, Kamil 
249faa34ccfSEd Tanous     fillSessionObject(asyncResp->res, *session);
250724340d7SEd Tanous }
251a1e0871dSEd Tanous inline void handleSessionServiceHead(
252a1e0871dSEd Tanous     crow::App& app, const crow::Request& req,
253a1e0871dSEd Tanous     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
254a1e0871dSEd Tanous {
255a1e0871dSEd Tanous     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
256a1e0871dSEd Tanous     {
257a1e0871dSEd Tanous         return;
258a1e0871dSEd Tanous     }
259a1e0871dSEd Tanous     asyncResp->res.addHeader(
260a1e0871dSEd Tanous         boost::beast::http::field::link,
261a1e0871dSEd Tanous         "</redfish/v1/JsonSchemas/SessionService/SessionService.json>; rel=describedby");
262a1e0871dSEd Tanous }
263724340d7SEd Tanous inline void
26445ca1b86SEd Tanous     handleSessionServiceGet(crow::App& app, const crow::Request& req,
265724340d7SEd Tanous                             const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
2662b7981f6SKowalski, Kamil 
267724340d7SEd Tanous {
26878e3900fSGunnar Mills     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
26978e3900fSGunnar Mills     {
27078e3900fSGunnar Mills         return;
27178e3900fSGunnar Mills     }
27278e3900fSGunnar Mills     asyncResp->res.addHeader(
27378e3900fSGunnar Mills         boost::beast::http::field::link,
27478e3900fSGunnar Mills         "</redfish/v1/JsonSchemas/SessionService/SessionService.json>; rel=describedby");
27578e3900fSGunnar Mills 
2768d1b46d7Szhanghch05     asyncResp->res.jsonValue["@odata.type"] =
2778d1b46d7Szhanghch05         "#SessionService.v1_0_2.SessionService";
278724340d7SEd Tanous     asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/SessionService/";
2798d1b46d7Szhanghch05     asyncResp->res.jsonValue["Name"] = "Session Service";
2808d1b46d7Szhanghch05     asyncResp->res.jsonValue["Id"] = "SessionService";
2818d1b46d7Szhanghch05     asyncResp->res.jsonValue["Description"] = "Session Service";
2828d1b46d7Szhanghch05     asyncResp->res.jsonValue["SessionTimeout"] =
283724340d7SEd Tanous         persistent_data::SessionStore::getInstance().getTimeoutInSeconds();
2848d1b46d7Szhanghch05     asyncResp->res.jsonValue["ServiceEnabled"] = true;
2850f74e643SEd Tanous 
2861476687dSEd Tanous     asyncResp->res.jsonValue["Sessions"]["@odata.id"] =
2871476687dSEd Tanous         "/redfish/v1/SessionService/Sessions";
288724340d7SEd Tanous }
289f2a4a606SManojkiran Eda 
290724340d7SEd Tanous inline void handleSessionServicePatch(
29145ca1b86SEd Tanous     crow::App& app, const crow::Request& req,
292724340d7SEd Tanous     const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
293724340d7SEd Tanous {
2943ba00073SCarson Labrado     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
29545ca1b86SEd Tanous     {
29645ca1b86SEd Tanous         return;
29745ca1b86SEd Tanous     }
298f2a4a606SManojkiran Eda     std::optional<int64_t> sessionTimeout;
299724340d7SEd Tanous     if (!json_util::readJsonPatch(req, asyncResp->res, "SessionTimeout",
300724340d7SEd Tanous                                   sessionTimeout))
301f2a4a606SManojkiran Eda     {
302f2a4a606SManojkiran Eda         return;
303f2a4a606SManojkiran Eda     }
304f2a4a606SManojkiran Eda 
305f2a4a606SManojkiran Eda     if (sessionTimeout)
306f2a4a606SManojkiran Eda     {
307faa34ccfSEd Tanous         // The mininum & maximum allowed values for session timeout
308faa34ccfSEd Tanous         // are 30 seconds and 86400 seconds respectively as per the
309faa34ccfSEd Tanous         // session service schema mentioned at
310f2a4a606SManojkiran Eda         // https://redfish.dmtf.org/schemas/v1/SessionService.v1_1_7.json
311f2a4a606SManojkiran Eda 
312f2a4a606SManojkiran Eda         if (*sessionTimeout <= 86400 && *sessionTimeout >= 30)
313f2a4a606SManojkiran Eda         {
314724340d7SEd Tanous             std::chrono::seconds sessionTimeoutInseconds(*sessionTimeout);
315724340d7SEd Tanous             persistent_data::SessionStore::getInstance().updateSessionTimeout(
316724340d7SEd Tanous                 sessionTimeoutInseconds);
317724340d7SEd Tanous             messages::propertyValueModified(asyncResp->res, "SessionTimeOut",
318f2a4a606SManojkiran Eda                                             std::to_string(*sessionTimeout));
319f2a4a606SManojkiran Eda         }
320f2a4a606SManojkiran Eda         else
321f2a4a606SManojkiran Eda         {
322724340d7SEd Tanous             messages::propertyValueNotInList(asyncResp->res,
323724340d7SEd Tanous                                              std::to_string(*sessionTimeout),
3248d1b46d7Szhanghch05                                              "SessionTimeOut");
325f2a4a606SManojkiran Eda         }
326f2a4a606SManojkiran Eda     }
327724340d7SEd Tanous }
328724340d7SEd Tanous 
329724340d7SEd Tanous inline void requestRoutesSession(App& app)
330724340d7SEd Tanous {
331724340d7SEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/<str>/")
332a1e0871dSEd Tanous         .privileges(redfish::privileges::headSession)
333a1e0871dSEd Tanous         .methods(boost::beast::http::verb::head)(
334a1e0871dSEd Tanous             std::bind_front(handleSessionHead, std::ref(app)));
335a1e0871dSEd Tanous 
336a1e0871dSEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/<str>/")
337724340d7SEd Tanous         .privileges(redfish::privileges::getSession)
33845ca1b86SEd Tanous         .methods(boost::beast::http::verb::get)(
33945ca1b86SEd Tanous             std::bind_front(handleSessionGet, std::ref(app)));
340724340d7SEd Tanous 
341724340d7SEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/<str>/")
342724340d7SEd Tanous         .privileges(redfish::privileges::deleteSession)
34345ca1b86SEd Tanous         .methods(boost::beast::http::verb::delete_)(
34445ca1b86SEd Tanous             std::bind_front(handleSessionDelete, std::ref(app)));
345724340d7SEd Tanous 
346724340d7SEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/")
347a1e0871dSEd Tanous         .privileges(redfish::privileges::headSessionCollection)
348a1e0871dSEd Tanous         .methods(boost::beast::http::verb::head)(
349a1e0871dSEd Tanous             std::bind_front(handleSessionCollectionHead, std::ref(app)));
350a1e0871dSEd Tanous 
351a1e0871dSEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/")
352724340d7SEd Tanous         .privileges(redfish::privileges::getSessionCollection)
35345ca1b86SEd Tanous         .methods(boost::beast::http::verb::get)(
35445ca1b86SEd Tanous             std::bind_front(handleSessionCollectionGet, std::ref(app)));
355724340d7SEd Tanous 
356e76cd868SEd Tanous     // Note, the next two routes technically don't match the privilege
357724340d7SEd Tanous     // registry given the way login mechanisms work.  The base privilege
358724340d7SEd Tanous     // registry lists this endpoint as requiring login privilege, but because
359724340d7SEd Tanous     // this is the endpoint responsible for giving the login privilege, and it
360724340d7SEd Tanous     // is itself its own route, it needs to not require Login
361724340d7SEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/")
362724340d7SEd Tanous         .privileges({})
36345ca1b86SEd Tanous         .methods(boost::beast::http::verb::post)(
36445ca1b86SEd Tanous             std::bind_front(handleSessionCollectionPost, std::ref(app)));
365724340d7SEd Tanous 
366e76cd868SEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/SessionService/Sessions/Members/")
367e76cd868SEd Tanous         .privileges({})
36845ca1b86SEd Tanous         .methods(boost::beast::http::verb::post)(
36945ca1b86SEd Tanous             std::bind_front(handleSessionCollectionPost, std::ref(app)));
370e76cd868SEd Tanous 
371724340d7SEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/SessionService/")
372a1e0871dSEd Tanous         .privileges(redfish::privileges::headSessionService)
373a1e0871dSEd Tanous         .methods(boost::beast::http::verb::head)(
374a1e0871dSEd Tanous             std::bind_front(handleSessionServiceHead, std::ref(app)));
375a1e0871dSEd Tanous 
376a1e0871dSEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/SessionService/")
377724340d7SEd Tanous         .privileges(redfish::privileges::getSessionService)
37845ca1b86SEd Tanous         .methods(boost::beast::http::verb::get)(
37945ca1b86SEd Tanous             std::bind_front(handleSessionServiceGet, std::ref(app)));
380724340d7SEd Tanous 
381724340d7SEd Tanous     BMCWEB_ROUTE(app, "/redfish/v1/SessionService/")
382724340d7SEd Tanous         .privileges(redfish::privileges::patchSessionService)
38345ca1b86SEd Tanous         .methods(boost::beast::http::verb::patch)(
38445ca1b86SEd Tanous             std::bind_front(handleSessionServicePatch, std::ref(app)));
385f2a4a606SManojkiran Eda }
3865d27b854SBorawski.Lukasz 
3872b7981f6SKowalski, Kamil } // namespace redfish
388