summaryrefslogtreecommitdiff
path: root/redfish-core/lib/redfish_sessions.hpp
diff options
context:
space:
mode:
authorSunitha Harish <sunithaharish04@gmail.com>2020-05-12 13:17:57 +0300
committerSunitha Harish <sunithaharish04@gmail.com>2020-06-17 07:22:05 +0300
commit08bdcc71e5804db9b5c35361e8456e636d258b04 (patch)
tree9a2d82d50821a2faf833916eb41f10ddc0701626 /redfish-core/lib/redfish_sessions.hpp
parent8114bd4d9ba4b927ecd2c2eeb3fc0885f684ad25 (diff)
downloadbmcweb-08bdcc71e5804db9b5c35361e8456e636d258b04.tar.xz
Session creation : Get and Set Oem ClientID
This commit implements handling the OemSession ClientID parameter for the IBM management console. Each session gets a random generated unique Id (Resource Id); but this Id is not a parameter that the client can set to a well known identifier. This Oem parameter ClientID is the string which the client can supply to uniquely identify itself among other sessions in the BMC. This is a read-only property which shall be passed in only during the session creation. 1. Create session by supplying the ClientID Oem parameter 2. Display the ClientID associated with the session 3. Persist the ClientID across BMC reboot Tested by: ============ 1. POST https://${bmc}/redfish/v1/SessionService/Sessions -d '{"UserName":"root", "Password":<>, "Oem":{"OpenBMC" : {"ClientID":"<client unique id>"}}}' 2. GET https://${bmc}/redfish/v1/SessionService/Sessions/<id> { "@odata.id": "/redfish/v1/SessionService/Sessions/<id>", "@odata.type": "#Session.v1_0_2.Session", "Description": "Manager User Session", "Id": "<id>", "Name": "User Session", "Oem": { "OpenBMC": { "@odata.type": "#OemSession.v1_0_0.Session", "ClientID": "<client unique id>" } }, "UserName": "root" } 3. Verified the session creation works fine without the Oem parameters. 4. Redfish validator Signed-off-by: Sunitha Harish <sunithaharish04@gmail.com> Change-Id: Ia740a610e3974dc3781bcee702c74ded9903944a
Diffstat (limited to 'redfish-core/lib/redfish_sessions.hpp')
-rw-r--r--redfish-core/lib/redfish_sessions.hpp30
1 files changed, 26 insertions, 4 deletions
diff --git a/redfish-core/lib/redfish_sessions.hpp b/redfish-core/lib/redfish_sessions.hpp
index 515f5bea63..4dbb64daba 100644
--- a/redfish-core/lib/redfish_sessions.hpp
+++ b/redfish-core/lib/redfish_sessions.hpp
@@ -63,7 +63,11 @@ class Sessions : public Node
res.jsonValue["@odata.type"] = "#Session.v1_0_2.Session";
res.jsonValue["Name"] = "User Session";
res.jsonValue["Description"] = "Manager User Session";
-
+#ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE
+ res.jsonValue["Oem"]["OpenBMC"]["@odata.type"] =
+ "#OemSession.v1_0_0.Session";
+ res.jsonValue["Oem"]["OpenBMC"]["ClientID"] = session->clientId;
+#endif
res.end();
}
@@ -168,8 +172,10 @@ class SessionCollection : public Node
{
std::string username;
std::string password;
+ std::optional<nlohmann::json> oemObject;
+ std::string clientId;
if (!json_util::readJson(req, res, "UserName", username, "Password",
- password))
+ password, "Oem", oemObject))
{
res.end();
return;
@@ -202,13 +208,29 @@ class SessionCollection : public Node
return;
}
-
+#ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE
+ if (oemObject)
+ {
+ std::optional<nlohmann::json> bmcOem;
+ if (!json_util::readJson(*oemObject, res, "OpenBMC", bmcOem))
+ {
+ res.end();
+ return;
+ }
+ if (!json_util::readJson(*bmcOem, res, "ClientID", clientId))
+ {
+ BMCWEB_LOG_ERROR << "Could not read ClientId";
+ res.end();
+ return;
+ }
+ }
+#endif
// User is authenticated - create session
std::shared_ptr<crow::persistent_data::UserSession> session =
crow::persistent_data::SessionStore::getInstance()
.generateUserSession(
username, crow::persistent_data::PersistenceType::TIMEOUT,
- isConfigureSelfOnly);
+ isConfigureSelfOnly, clientId);
res.addHeader("X-Auth-Token", session->sessionToken);
res.addHeader("Location", "/redfish/v1/SessionService/Sessions/" +
session->uniqueId);