From bb759e3aeaadfec9f3aac4485f253bcc8a523e4c Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Tue, 2 Aug 2022 17:07:54 -0700 Subject: Move ClientID parameter out of OEM In 2022.2, Redfish added support for the Context parameter on the Session Resource. This parameter has the same function that the OemSession.ClientId field served. This commit moves all the existing ClientId code to produce Context as well. Functionally, this has one important difference, in that Context in Redfish is optionally provided by the user, which means we need to omit it if not given by the user. The old implementation left it set to empty string (""). Because of this, a few minor interfaces need to change to use std::optional. Existing uses of clientId are moved to using value_or("") to keep the same behavior as before. Tested: curl --insecure -X POST -d "{\"UserName\": \"root\", \"Password\": \"0penBmc\"}" https://192.168.7.2/redfish/v1/SessionService/Sessions Returns a Session object with no Context key present curl --insecure -X POST -d "{\"UserName\": \"root\", \"Password\": \"0penBmc\", \"Context\": \"Foobar\"}" https://192.168.7.2/redfish/v1/SessionService/Sessions Returns a Session object with: "Context": "Foobar" Subsequent Gets of /redfish/v1/SessionService/Sessions/ return the same session objects, both with and without Context. Signed-off-by: Ed Tanous Change-Id: I4df358623f93f3e6cb659e99970ad909cefebc62 --- include/persistent_data.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include/persistent_data.hpp') diff --git a/include/persistent_data.hpp b/include/persistent_data.hpp index de5d6780f8..7478713161 100644 --- a/include/persistent_data.hpp +++ b/include/persistent_data.hpp @@ -239,9 +239,10 @@ class ConfigFile session["username"] = p.second->username; session["csrf_token"] = p.second->csrfToken; session["client_ip"] = p.second->clientIp; -#ifdef BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE - session["client_id"] = p.second->clientId; -#endif + if (p.second->clientId) + { + session["client_id"] = *p.second->clientId; + } sessions.push_back(std::move(session)); } } -- cgit v1.2.3