blob: 27030089232f67dd758cd1b8330d9dfa0e0e0706 [file] [log] [blame]
Lewanczyk, Dawid88d16c92018-02-02 14:51:09 +01001/*
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
Lewanczyk, Dawid88d16c92018-02-02 14:51:09 +010017#include "node.hpp"
18
Ratan Gupta24c85422019-01-30 19:41:24 +053019#include <dbus_utility.hpp>
Ed Tanous65b0dc32018-09-19 16:04:03 -070020#include <error_messages.hpp>
Ed Tanousb9b2e0b2018-09-13 13:47:50 -070021#include <openbmc_dbus_rest.hpp>
Ed Tanous52cc1122020-07-18 13:51:21 -070022#include <persistent_data.hpp>
Ed Tanousa8408792018-09-05 16:08:38 -070023#include <utils/json_utils.hpp>
Gunnar Mills1214b7e2020-06-04 10:11:30 -050024
Ed Tanousabf2add2019-01-22 16:40:12 -080025#include <variant>
Ed Tanousb9b2e0b2018-09-13 13:47:50 -070026
Ed Tanous1abe55e2018-09-05 08:30:59 -070027namespace redfish
28{
Lewanczyk, Dawid88d16c92018-02-02 14:51:09 +010029
Ed Tanous23a21a12020-07-25 04:45:05 +000030constexpr const char* ldapConfigObjectName =
Ratan Gupta6973a582018-12-13 18:25:44 +053031 "/xyz/openbmc_project/user/ldap/openldap";
Ed Tanous2c70f802020-09-28 14:29:23 -070032constexpr const char* adConfigObject =
Ratan Guptaab828d72019-04-22 14:18:33 +053033 "/xyz/openbmc_project/user/ldap/active_directory";
34
Ratan Gupta6973a582018-12-13 18:25:44 +053035constexpr const char* ldapRootObject = "/xyz/openbmc_project/user/ldap";
36constexpr const char* ldapDbusService = "xyz.openbmc_project.Ldap.Config";
37constexpr const char* ldapConfigInterface =
38 "xyz.openbmc_project.User.Ldap.Config";
39constexpr const char* ldapCreateInterface =
40 "xyz.openbmc_project.User.Ldap.Create";
41constexpr const char* ldapEnableInterface = "xyz.openbmc_project.Object.Enable";
Ratan Gupta06785242019-07-26 22:30:16 +053042constexpr const char* ldapPrivMapperInterface =
43 "xyz.openbmc_project.User.PrivilegeMapper";
Ratan Gupta6973a582018-12-13 18:25:44 +053044constexpr const char* dbusObjManagerIntf = "org.freedesktop.DBus.ObjectManager";
45constexpr const char* propertyInterface = "org.freedesktop.DBus.Properties";
46constexpr const char* mapperBusName = "xyz.openbmc_project.ObjectMapper";
47constexpr const char* mapperObjectPath = "/xyz/openbmc_project/object_mapper";
48constexpr const char* mapperIntf = "xyz.openbmc_project.ObjectMapper";
49
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -060050struct LDAPRoleMapData
51{
52 std::string groupName;
53 std::string privilege;
54};
55
Ratan Gupta6973a582018-12-13 18:25:44 +053056struct LDAPConfigData
57{
58 std::string uri{};
59 std::string bindDN{};
60 std::string baseDN{};
61 std::string searchScope{};
62 std::string serverType{};
63 bool serviceEnabled = false;
64 std::string userNameAttribute{};
65 std::string groupAttribute{};
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -060066 std::vector<std::pair<std::string, LDAPRoleMapData>> groupRoleList;
Ratan Gupta6973a582018-12-13 18:25:44 +053067};
68
Patrick Williams19bd78d2020-05-13 17:38:24 -050069using DbusVariantType = std::variant<bool, int32_t, std::string>;
Przemyslaw Czarnowski107077d2019-07-11 10:16:43 +020070
71using DbusInterfaceType = boost::container::flat_map<
72 std::string, boost::container::flat_map<std::string, DbusVariantType>>;
73
74using ManagedObjectType =
75 std::vector<std::pair<sdbusplus::message::object_path, DbusInterfaceType>>;
76
Ratan Gupta6973a582018-12-13 18:25:44 +053077using GetObjectType =
78 std::vector<std::pair<std::string, std::vector<std::string>>>;
AppaRao Puli84e12cb2018-10-11 01:28:15 +053079
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -060080inline std::string getRoleIdFromPrivilege(std::string_view role)
AppaRao Puli84e12cb2018-10-11 01:28:15 +053081{
82 if (role == "priv-admin")
83 {
84 return "Administrator";
85 }
Ed Tanous3174e4d2020-10-07 11:41:22 -070086 if (role == "priv-user")
AppaRao Puli84e12cb2018-10-11 01:28:15 +053087 {
AppaRao Pulic80fee52019-10-16 14:49:36 +053088 return "ReadOnly";
AppaRao Puli84e12cb2018-10-11 01:28:15 +053089 }
Ed Tanous3174e4d2020-10-07 11:41:22 -070090 if (role == "priv-operator")
AppaRao Puli84e12cb2018-10-11 01:28:15 +053091 {
92 return "Operator";
93 }
Ed Tanous3174e4d2020-10-07 11:41:22 -070094 if ((role == "") || (role == "priv-noaccess"))
jayaprakash Mutyalae9e6d242019-07-29 11:59:08 +000095 {
96 return "NoAccess";
97 }
AppaRao Puli84e12cb2018-10-11 01:28:15 +053098 return "";
99}
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600100inline std::string getPrivilegeFromRoleId(std::string_view role)
AppaRao Puli84e12cb2018-10-11 01:28:15 +0530101{
102 if (role == "Administrator")
103 {
104 return "priv-admin";
105 }
Ed Tanous3174e4d2020-10-07 11:41:22 -0700106 if (role == "ReadOnly")
AppaRao Puli84e12cb2018-10-11 01:28:15 +0530107 {
108 return "priv-user";
109 }
Ed Tanous3174e4d2020-10-07 11:41:22 -0700110 if (role == "Operator")
AppaRao Puli84e12cb2018-10-11 01:28:15 +0530111 {
112 return "priv-operator";
113 }
Ed Tanous3174e4d2020-10-07 11:41:22 -0700114 if ((role == "NoAccess") || (role == ""))
jayaprakash Mutyalae9e6d242019-07-29 11:59:08 +0000115 {
116 return "priv-noaccess";
117 }
AppaRao Puli84e12cb2018-10-11 01:28:15 +0530118 return "";
119}
Ed Tanousb9b2e0b2018-09-13 13:47:50 -0700120
Ed Tanous23a21a12020-07-25 04:45:05 +0000121inline void userErrorMessageHandler(const sd_bus_error* e,
Ed Tanousb5a76932020-09-29 16:16:58 -0700122 const std::shared_ptr<AsyncResp>& asyncResp,
Ed Tanous23a21a12020-07-25 04:45:05 +0000123 const std::string& newUser,
124 const std::string& username)
jayaprakash Mutyala66b5ca72019-08-07 20:26:37 +0000125{
jayaprakash Mutyala66b5ca72019-08-07 20:26:37 +0000126 if (e == nullptr)
127 {
128 messages::internalError(asyncResp->res);
129 return;
130 }
131
Manojkiran Eda055806b2020-11-03 09:36:28 +0530132 const char* errorMessage = e->name;
jayaprakash Mutyala66b5ca72019-08-07 20:26:37 +0000133 if (strcmp(errorMessage,
134 "xyz.openbmc_project.User.Common.Error.UserNameExists") == 0)
135 {
136 messages::resourceAlreadyExists(asyncResp->res,
Gunnar Mills8114bd42020-06-11 20:55:21 -0500137 "#ManagerAccount.v1_4_0.ManagerAccount",
jayaprakash Mutyala66b5ca72019-08-07 20:26:37 +0000138 "UserName", newUser);
139 }
140 else if (strcmp(errorMessage, "xyz.openbmc_project.User.Common.Error."
141 "UserNameDoesNotExist") == 0)
142 {
143 messages::resourceNotFound(
Gunnar Mills8114bd42020-06-11 20:55:21 -0500144 asyncResp->res, "#ManagerAccount.v1_4_0.ManagerAccount", username);
jayaprakash Mutyala66b5ca72019-08-07 20:26:37 +0000145 }
Ed Tanousd4d25792020-09-29 15:15:03 -0700146 else if ((strcmp(errorMessage,
147 "xyz.openbmc_project.Common.Error.InvalidArgument") ==
148 0) ||
149 (strcmp(errorMessage, "xyz.openbmc_project.User.Common.Error."
150 "UserNameGroupFail") == 0))
jayaprakash Mutyala66b5ca72019-08-07 20:26:37 +0000151 {
152 messages::propertyValueFormatError(asyncResp->res, newUser, "UserName");
153 }
154 else if (strcmp(errorMessage,
155 "xyz.openbmc_project.User.Common.Error.NoResource") == 0)
156 {
157 messages::createLimitReachedForResource(asyncResp->res);
158 }
jayaprakash Mutyala66b5ca72019-08-07 20:26:37 +0000159 else
160 {
161 messages::internalError(asyncResp->res);
162 }
163
164 return;
165}
166
Ed Tanous81ce6092020-12-17 16:54:55 +0000167inline void parseLDAPConfigData(nlohmann::json& jsonResponse,
Ed Tanous23a21a12020-07-25 04:45:05 +0000168 const LDAPConfigData& confData,
169 const std::string& ldapType)
Ratan Gupta6973a582018-12-13 18:25:44 +0530170{
Ratan Guptaab828d72019-04-22 14:18:33 +0530171 std::string service =
172 (ldapType == "LDAP") ? "LDAPService" : "ActiveDirectoryService";
Marri Devender Rao37cce912019-02-20 01:05:22 -0600173 nlohmann::json ldap = {
Ratan Gupta6973a582018-12-13 18:25:44 +0530174 {"ServiceEnabled", confData.serviceEnabled},
175 {"ServiceAddresses", nlohmann::json::array({confData.uri})},
176 {"Authentication",
177 {{"AuthenticationType", "UsernameAndPassword"},
Ratan Gupta6973a582018-12-13 18:25:44 +0530178 {"Username", confData.bindDN},
179 {"Password", nullptr}}},
180 {"LDAPService",
181 {{"SearchSettings",
182 {{"BaseDistinguishedNames",
183 nlohmann::json::array({confData.baseDN})},
184 {"UsernameAttribute", confData.userNameAttribute},
185 {"GroupsAttribute", confData.groupAttribute}}}}},
186 };
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600187
Ed Tanous81ce6092020-12-17 16:54:55 +0000188 jsonResponse[ldapType].update(ldap);
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600189
Ed Tanous81ce6092020-12-17 16:54:55 +0000190 nlohmann::json& roleMapArray = jsonResponse[ldapType]["RemoteRoleMapping"];
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600191 roleMapArray = nlohmann::json::array();
192 for (auto& obj : confData.groupRoleList)
193 {
194 BMCWEB_LOG_DEBUG << "Pushing the data groupName="
195 << obj.second.groupName << "\n";
196 roleMapArray.push_back(
197 {nlohmann::json::array({"RemoteGroup", obj.second.groupName}),
198 nlohmann::json::array(
199 {"LocalRole", getRoleIdFromPrivilege(obj.second.privilege)})});
200 }
Ratan Gupta6973a582018-12-13 18:25:44 +0530201}
202
203/**
Ratan Gupta06785242019-07-26 22:30:16 +0530204 * @brief validates given JSON input and then calls appropriate method to
205 * create, to delete or to set Rolemapping object based on the given input.
206 *
207 */
Ed Tanous23a21a12020-07-25 04:45:05 +0000208inline void handleRoleMapPatch(
Ratan Gupta06785242019-07-26 22:30:16 +0530209 const std::shared_ptr<AsyncResp>& asyncResp,
210 const std::vector<std::pair<std::string, LDAPRoleMapData>>& roleMapObjData,
Ed Tanousf23b7292020-10-15 09:41:17 -0700211 const std::string& serverType, const std::vector<nlohmann::json>& input)
Ratan Gupta06785242019-07-26 22:30:16 +0530212{
213 for (size_t index = 0; index < input.size(); index++)
214 {
Ed Tanousf23b7292020-10-15 09:41:17 -0700215 const nlohmann::json& thisJson = input[index];
Ratan Gupta06785242019-07-26 22:30:16 +0530216
217 if (thisJson.is_null())
218 {
219 // delete the existing object
220 if (index < roleMapObjData.size())
221 {
222 crow::connections::systemBus->async_method_call(
223 [asyncResp, roleMapObjData, serverType,
224 index](const boost::system::error_code ec) {
225 if (ec)
226 {
227 BMCWEB_LOG_ERROR << "DBUS response error: " << ec;
228 messages::internalError(asyncResp->res);
229 return;
230 }
231 asyncResp->res
232 .jsonValue[serverType]["RemoteRoleMapping"][index] =
233 nullptr;
234 },
235 ldapDbusService, roleMapObjData[index].first,
236 "xyz.openbmc_project.Object.Delete", "Delete");
237 }
238 else
239 {
240 BMCWEB_LOG_ERROR << "Can't delete the object";
241 messages::propertyValueTypeError(
Ed Tanous71f52d92021-02-19 08:51:17 -0800242 asyncResp->res,
243 thisJson.dump(2, ' ', true,
244 nlohmann::json::error_handler_t::replace),
Ratan Gupta06785242019-07-26 22:30:16 +0530245 "RemoteRoleMapping/" + std::to_string(index));
246 return;
247 }
248 }
249 else if (thisJson.empty())
250 {
251 // Don't do anything for the empty objects,parse next json
252 // eg {"RemoteRoleMapping",[{}]}
253 }
254 else
255 {
256 // update/create the object
257 std::optional<std::string> remoteGroup;
258 std::optional<std::string> localRole;
259
Ed Tanousf23b7292020-10-15 09:41:17 -0700260 // This is a copy, but it's required in this case because of how
261 // readJson is structured
262 nlohmann::json thisJsonCopy = thisJson;
263 if (!json_util::readJson(thisJsonCopy, asyncResp->res,
264 "RemoteGroup", remoteGroup, "LocalRole",
265 localRole))
Ratan Gupta06785242019-07-26 22:30:16 +0530266 {
267 continue;
268 }
269
270 // Update existing RoleMapping Object
271 if (index < roleMapObjData.size())
272 {
273 BMCWEB_LOG_DEBUG << "Update Role Map Object";
274 // If "RemoteGroup" info is provided
275 if (remoteGroup)
276 {
277 crow::connections::systemBus->async_method_call(
278 [asyncResp, roleMapObjData, serverType, index,
279 remoteGroup](const boost::system::error_code ec) {
280 if (ec)
281 {
282 BMCWEB_LOG_ERROR << "DBUS response error: "
283 << ec;
284 messages::internalError(asyncResp->res);
285 return;
286 }
287 asyncResp->res
288 .jsonValue[serverType]["RemoteRoleMapping"]
289 [index]["RemoteGroup"] = *remoteGroup;
290 },
291 ldapDbusService, roleMapObjData[index].first,
292 propertyInterface, "Set",
293 "xyz.openbmc_project.User.PrivilegeMapperEntry",
294 "GroupName",
295 std::variant<std::string>(std::move(*remoteGroup)));
296 }
297
298 // If "LocalRole" info is provided
299 if (localRole)
300 {
301 crow::connections::systemBus->async_method_call(
302 [asyncResp, roleMapObjData, serverType, index,
303 localRole](const boost::system::error_code ec) {
304 if (ec)
305 {
306 BMCWEB_LOG_ERROR << "DBUS response error: "
307 << ec;
308 messages::internalError(asyncResp->res);
309 return;
310 }
311 asyncResp->res
312 .jsonValue[serverType]["RemoteRoleMapping"]
313 [index]["LocalRole"] = *localRole;
314 },
315 ldapDbusService, roleMapObjData[index].first,
316 propertyInterface, "Set",
317 "xyz.openbmc_project.User.PrivilegeMapperEntry",
318 "Privilege",
319 std::variant<std::string>(
320 getPrivilegeFromRoleId(std::move(*localRole))));
321 }
322 }
323 // Create a new RoleMapping Object.
324 else
325 {
326 BMCWEB_LOG_DEBUG
327 << "setRoleMappingProperties: Creating new Object";
328 std::string pathString =
329 "RemoteRoleMapping/" + std::to_string(index);
330
331 if (!localRole)
332 {
333 messages::propertyMissing(asyncResp->res,
334 pathString + "/LocalRole");
335 continue;
336 }
337 if (!remoteGroup)
338 {
339 messages::propertyMissing(asyncResp->res,
340 pathString + "/RemoteGroup");
341 continue;
342 }
343
344 std::string dbusObjectPath;
345 if (serverType == "ActiveDirectory")
346 {
Ed Tanous2c70f802020-09-28 14:29:23 -0700347 dbusObjectPath = adConfigObject;
Ratan Gupta06785242019-07-26 22:30:16 +0530348 }
349 else if (serverType == "LDAP")
350 {
Ed Tanous23a21a12020-07-25 04:45:05 +0000351 dbusObjectPath = ldapConfigObjectName;
Ratan Gupta06785242019-07-26 22:30:16 +0530352 }
353
354 BMCWEB_LOG_DEBUG << "Remote Group=" << *remoteGroup
355 << ",LocalRole=" << *localRole;
356
357 crow::connections::systemBus->async_method_call(
Ed Tanous271584a2019-07-09 16:24:22 -0700358 [asyncResp, serverType, localRole,
Ratan Gupta06785242019-07-26 22:30:16 +0530359 remoteGroup](const boost::system::error_code ec) {
360 if (ec)
361 {
362 BMCWEB_LOG_ERROR << "DBUS response error: " << ec;
363 messages::internalError(asyncResp->res);
364 return;
365 }
366 nlohmann::json& remoteRoleJson =
367 asyncResp->res
368 .jsonValue[serverType]["RemoteRoleMapping"];
369 remoteRoleJson.push_back(
370 {{"LocalRole", *localRole},
371 {"RemoteGroup", *remoteGroup}});
372 },
373 ldapDbusService, dbusObjectPath, ldapPrivMapperInterface,
Ed Tanous3174e4d2020-10-07 11:41:22 -0700374 "Create", *remoteGroup,
Ratan Gupta06785242019-07-26 22:30:16 +0530375 getPrivilegeFromRoleId(std::move(*localRole)));
376 }
377 }
378 }
379}
380
381/**
Ratan Gupta6973a582018-12-13 18:25:44 +0530382 * Function that retrieves all properties for LDAP config object
383 * into JSON
384 */
385template <typename CallbackFunc>
386inline void getLDAPConfigData(const std::string& ldapType,
387 CallbackFunc&& callback)
388{
Ratan Guptaab828d72019-04-22 14:18:33 +0530389
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600390 const std::array<const char*, 2> interfaces = {ldapEnableInterface,
Ratan Gupta6973a582018-12-13 18:25:44 +0530391 ldapConfigInterface};
392
393 crow::connections::systemBus->async_method_call(
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600394 [callback, ldapType](const boost::system::error_code ec,
395 const GetObjectType& resp) {
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600396 if (ec || resp.empty())
397 {
398 BMCWEB_LOG_ERROR << "DBUS response error during getting of "
399 "service name: "
400 << ec;
Ed Tanous23a21a12020-07-25 04:45:05 +0000401 LDAPConfigData empty{};
402 callback(false, empty, ldapType);
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600403 return;
404 }
405 std::string service = resp.begin()->first;
406 crow::connections::systemBus->async_method_call(
Ed Tanous81ce6092020-12-17 16:54:55 +0000407 [callback, ldapType](const boost::system::error_code errorCode,
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600408 const ManagedObjectType& ldapObjects) {
409 LDAPConfigData confData{};
Ed Tanous81ce6092020-12-17 16:54:55 +0000410 if (errorCode)
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600411 {
412 callback(false, confData, ldapType);
413 BMCWEB_LOG_ERROR << "D-Bus responses error: "
Ed Tanous81ce6092020-12-17 16:54:55 +0000414 << errorCode;
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600415 return;
416 }
417
418 std::string ldapDbusType;
419 std::string searchString;
420
421 if (ldapType == "LDAP")
422 {
423 ldapDbusType = "xyz.openbmc_project.User.Ldap.Config."
424 "Type.OpenLdap";
425 searchString = "openldap";
426 }
427 else if (ldapType == "ActiveDirectory")
428 {
429 ldapDbusType =
430 "xyz.openbmc_project.User.Ldap.Config.Type."
431 "ActiveDirectory";
432 searchString = "active_directory";
433 }
434 else
435 {
436 BMCWEB_LOG_ERROR
437 << "Can't get the DbusType for the given type="
438 << ldapType;
439 callback(false, confData, ldapType);
440 return;
441 }
442
443 std::string ldapEnableInterfaceStr = ldapEnableInterface;
444 std::string ldapConfigInterfaceStr = ldapConfigInterface;
445
446 for (const auto& object : ldapObjects)
447 {
448 // let's find the object whose ldap type is equal to the
449 // given type
450 if (object.first.str.find(searchString) ==
451 std::string::npos)
452 {
453 continue;
454 }
455
456 for (const auto& interface : object.second)
457 {
458 if (interface.first == ldapEnableInterfaceStr)
459 {
460 // rest of the properties are string.
461 for (const auto& property : interface.second)
462 {
463 if (property.first == "Enabled")
464 {
465 const bool* value =
466 std::get_if<bool>(&property.second);
467 if (value == nullptr)
468 {
469 continue;
470 }
471 confData.serviceEnabled = *value;
472 break;
473 }
474 }
475 }
476 else if (interface.first == ldapConfigInterfaceStr)
477 {
478
479 for (const auto& property : interface.second)
480 {
Ed Tanous271584a2019-07-09 16:24:22 -0700481 const std::string* strValue =
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600482 std::get_if<std::string>(
483 &property.second);
Ed Tanous271584a2019-07-09 16:24:22 -0700484 if (strValue == nullptr)
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600485 {
486 continue;
487 }
488 if (property.first == "LDAPServerURI")
489 {
Ed Tanous271584a2019-07-09 16:24:22 -0700490 confData.uri = *strValue;
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600491 }
492 else if (property.first == "LDAPBindDN")
493 {
Ed Tanous271584a2019-07-09 16:24:22 -0700494 confData.bindDN = *strValue;
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600495 }
496 else if (property.first == "LDAPBaseDN")
497 {
Ed Tanous271584a2019-07-09 16:24:22 -0700498 confData.baseDN = *strValue;
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600499 }
500 else if (property.first ==
501 "LDAPSearchScope")
502 {
Ed Tanous271584a2019-07-09 16:24:22 -0700503 confData.searchScope = *strValue;
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600504 }
505 else if (property.first ==
506 "GroupNameAttribute")
507 {
Ed Tanous271584a2019-07-09 16:24:22 -0700508 confData.groupAttribute = *strValue;
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600509 }
510 else if (property.first ==
511 "UserNameAttribute")
512 {
Ed Tanous271584a2019-07-09 16:24:22 -0700513 confData.userNameAttribute = *strValue;
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600514 }
515 else if (property.first == "LDAPType")
516 {
Ed Tanous271584a2019-07-09 16:24:22 -0700517 confData.serverType = *strValue;
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600518 }
519 }
520 }
521 else if (interface.first ==
522 "xyz.openbmc_project.User."
523 "PrivilegeMapperEntry")
524 {
525 LDAPRoleMapData roleMapData{};
526 for (const auto& property : interface.second)
527 {
Ed Tanous271584a2019-07-09 16:24:22 -0700528 const std::string* strValue =
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600529 std::get_if<std::string>(
530 &property.second);
531
Ed Tanous271584a2019-07-09 16:24:22 -0700532 if (strValue == nullptr)
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600533 {
534 continue;
535 }
536
537 if (property.first == "GroupName")
538 {
Ed Tanous271584a2019-07-09 16:24:22 -0700539 roleMapData.groupName = *strValue;
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600540 }
541 else if (property.first == "Privilege")
542 {
Ed Tanous271584a2019-07-09 16:24:22 -0700543 roleMapData.privilege = *strValue;
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600544 }
545 }
546
Ed Tanous0f0353b2019-10-24 11:37:51 -0700547 confData.groupRoleList.emplace_back(
548 object.first.str, roleMapData);
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -0600549 }
550 }
551 }
552 callback(true, confData, ldapType);
553 },
554 service, ldapRootObject, dbusObjManagerIntf,
555 "GetManagedObjects");
556 },
557 mapperBusName, mapperObjectPath, mapperIntf, "GetObject",
Ed Tanous23a21a12020-07-25 04:45:05 +0000558 ldapConfigObjectName, interfaces);
Ratan Gupta6973a582018-12-13 18:25:44 +0530559}
560
Ed Tanous1abe55e2018-09-05 08:30:59 -0700561class AccountService : public Node
562{
563 public:
Ed Tanous23a21a12020-07-25 04:45:05 +0000564 AccountService(App& app) : Node(app, "/redfish/v1/AccountService/")
Ed Tanous1abe55e2018-09-05 08:30:59 -0700565 {
Ed Tanous1abe55e2018-09-05 08:30:59 -0700566 entityPrivileges = {
Gunnar Mills3c5a3762020-01-29 15:21:30 -0600567 {boost::beast::http::verb::get, {{"Login"}}},
Ed Tanous1abe55e2018-09-05 08:30:59 -0700568 {boost::beast::http::verb::head, {{"Login"}}},
569 {boost::beast::http::verb::patch, {{"ConfigureUsers"}}},
570 {boost::beast::http::verb::put, {{"ConfigureUsers"}}},
571 {boost::beast::http::verb::delete_, {{"ConfigureUsers"}}},
572 {boost::beast::http::verb::post, {{"ConfigureUsers"}}}};
573 }
Lewanczyk, Dawid88d16c92018-02-02 14:51:09 +0100574
Ed Tanous1abe55e2018-09-05 08:30:59 -0700575 private:
Ratan Gupta8a07d282019-03-16 08:33:47 +0530576 /**
577 * @brief parses the authentication section under the LDAP
578 * @param input JSON data
579 * @param asyncResp pointer to the JSON response
580 * @param userName userName to be filled from the given JSON.
581 * @param password password to be filled from the given JSON.
582 */
583 void
584 parseLDAPAuthenticationJson(nlohmann::json input,
585 const std::shared_ptr<AsyncResp>& asyncResp,
586 std::optional<std::string>& username,
587 std::optional<std::string>& password)
588 {
589 std::optional<std::string> authType;
590
591 if (!json_util::readJson(input, asyncResp->res, "AuthenticationType",
592 authType, "Username", username, "Password",
593 password))
594 {
595 return;
596 }
597 if (!authType)
598 {
599 return;
600 }
601 if (*authType != "UsernameAndPassword")
602 {
603 messages::propertyValueNotInList(asyncResp->res, *authType,
604 "AuthenticationType");
605 return;
606 }
607 }
608 /**
609 * @brief parses the LDAPService section under the LDAP
610 * @param input JSON data
611 * @param asyncResp pointer to the JSON response
612 * @param baseDNList baseDN to be filled from the given JSON.
613 * @param userNameAttribute userName to be filled from the given JSON.
614 * @param groupaAttribute password to be filled from the given JSON.
615 */
616
617 void parseLDAPServiceJson(
618 nlohmann::json input, const std::shared_ptr<AsyncResp>& asyncResp,
619 std::optional<std::vector<std::string>>& baseDNList,
620 std::optional<std::string>& userNameAttribute,
621 std::optional<std::string>& groupsAttribute)
622 {
623 std::optional<nlohmann::json> searchSettings;
624
625 if (!json_util::readJson(input, asyncResp->res, "SearchSettings",
626 searchSettings))
627 {
628 return;
629 }
630 if (!searchSettings)
631 {
632 return;
633 }
634 if (!json_util::readJson(*searchSettings, asyncResp->res,
635 "BaseDistinguishedNames", baseDNList,
636 "UsernameAttribute", userNameAttribute,
637 "GroupsAttribute", groupsAttribute))
638 {
639 return;
640 }
641 }
642 /**
643 * @brief updates the LDAP server address and updates the
644 json response with the new value.
645 * @param serviceAddressList address to be updated.
646 * @param asyncResp pointer to the JSON response
647 * @param ldapServerElementName Type of LDAP
648 server(openLDAP/ActiveDirectory)
649 */
650
651 void handleServiceAddressPatch(
652 const std::vector<std::string>& serviceAddressList,
653 const std::shared_ptr<AsyncResp>& asyncResp,
654 const std::string& ldapServerElementName,
655 const std::string& ldapConfigObject)
656 {
657 crow::connections::systemBus->async_method_call(
658 [asyncResp, ldapServerElementName,
659 serviceAddressList](const boost::system::error_code ec) {
660 if (ec)
661 {
662 BMCWEB_LOG_DEBUG
Gunnar Millsc61704a2020-07-08 13:47:06 -0500663 << "Error Occurred in updating the service address";
Ratan Gupta8a07d282019-03-16 08:33:47 +0530664 messages::internalError(asyncResp->res);
665 return;
666 }
667 std::vector<std::string> modifiedserviceAddressList = {
668 serviceAddressList.front()};
669 asyncResp->res
670 .jsonValue[ldapServerElementName]["ServiceAddresses"] =
671 modifiedserviceAddressList;
672 if ((serviceAddressList).size() > 1)
673 {
674 messages::propertyValueModified(asyncResp->res,
675 "ServiceAddresses",
676 serviceAddressList.front());
677 }
678 BMCWEB_LOG_DEBUG << "Updated the service address";
679 },
680 ldapDbusService, ldapConfigObject, propertyInterface, "Set",
681 ldapConfigInterface, "LDAPServerURI",
682 std::variant<std::string>(serviceAddressList.front()));
683 }
684 /**
685 * @brief updates the LDAP Bind DN and updates the
686 json response with the new value.
687 * @param username name of the user which needs to be updated.
688 * @param asyncResp pointer to the JSON response
689 * @param ldapServerElementName Type of LDAP
690 server(openLDAP/ActiveDirectory)
691 */
692
693 void handleUserNamePatch(const std::string& username,
694 const std::shared_ptr<AsyncResp>& asyncResp,
695 const std::string& ldapServerElementName,
696 const std::string& ldapConfigObject)
697 {
698 crow::connections::systemBus->async_method_call(
699 [asyncResp, username,
700 ldapServerElementName](const boost::system::error_code ec) {
701 if (ec)
702 {
703 BMCWEB_LOG_DEBUG
Gunnar Millsc61704a2020-07-08 13:47:06 -0500704 << "Error occurred in updating the username";
Ratan Gupta8a07d282019-03-16 08:33:47 +0530705 messages::internalError(asyncResp->res);
706 return;
707 }
708 asyncResp->res.jsonValue[ldapServerElementName]
709 ["Authentication"]["Username"] =
710 username;
711 BMCWEB_LOG_DEBUG << "Updated the username";
712 },
713 ldapDbusService, ldapConfigObject, propertyInterface, "Set",
714 ldapConfigInterface, "LDAPBindDN",
715 std::variant<std::string>(username));
716 }
717
718 /**
719 * @brief updates the LDAP password
720 * @param password : ldap password which needs to be updated.
721 * @param asyncResp pointer to the JSON response
722 * @param ldapServerElementName Type of LDAP
723 * server(openLDAP/ActiveDirectory)
724 */
725
726 void handlePasswordPatch(const std::string& password,
727 const std::shared_ptr<AsyncResp>& asyncResp,
728 const std::string& ldapServerElementName,
729 const std::string& ldapConfigObject)
730 {
731 crow::connections::systemBus->async_method_call(
732 [asyncResp, password,
733 ldapServerElementName](const boost::system::error_code ec) {
734 if (ec)
735 {
736 BMCWEB_LOG_DEBUG
Gunnar Millsc61704a2020-07-08 13:47:06 -0500737 << "Error occurred in updating the password";
Ratan Gupta8a07d282019-03-16 08:33:47 +0530738 messages::internalError(asyncResp->res);
739 return;
740 }
741 asyncResp->res.jsonValue[ldapServerElementName]
742 ["Authentication"]["Password"] = "";
743 BMCWEB_LOG_DEBUG << "Updated the password";
744 },
745 ldapDbusService, ldapConfigObject, propertyInterface, "Set",
746 ldapConfigInterface, "LDAPBindDNPassword",
747 std::variant<std::string>(password));
748 }
749
750 /**
751 * @brief updates the LDAP BaseDN and updates the
752 json response with the new value.
753 * @param baseDNList baseDN list which needs to be updated.
754 * @param asyncResp pointer to the JSON response
755 * @param ldapServerElementName Type of LDAP
756 server(openLDAP/ActiveDirectory)
757 */
758
759 void handleBaseDNPatch(const std::vector<std::string>& baseDNList,
760 const std::shared_ptr<AsyncResp>& asyncResp,
761 const std::string& ldapServerElementName,
762 const std::string& ldapConfigObject)
763 {
764 crow::connections::systemBus->async_method_call(
765 [asyncResp, baseDNList,
766 ldapServerElementName](const boost::system::error_code ec) {
767 if (ec)
768 {
Gunnar Millsc61704a2020-07-08 13:47:06 -0500769 BMCWEB_LOG_DEBUG
770 << "Error Occurred in Updating the base DN";
Ratan Gupta8a07d282019-03-16 08:33:47 +0530771 messages::internalError(asyncResp->res);
772 return;
773 }
774 auto& serverTypeJson =
775 asyncResp->res.jsonValue[ldapServerElementName];
776 auto& searchSettingsJson =
777 serverTypeJson["LDAPService"]["SearchSettings"];
778 std::vector<std::string> modifiedBaseDNList = {
779 baseDNList.front()};
780 searchSettingsJson["BaseDistinguishedNames"] =
781 modifiedBaseDNList;
782 if (baseDNList.size() > 1)
783 {
784 messages::propertyValueModified(asyncResp->res,
785 "BaseDistinguishedNames",
786 baseDNList.front());
787 }
788 BMCWEB_LOG_DEBUG << "Updated the base DN";
789 },
790 ldapDbusService, ldapConfigObject, propertyInterface, "Set",
791 ldapConfigInterface, "LDAPBaseDN",
792 std::variant<std::string>(baseDNList.front()));
793 }
794 /**
795 * @brief updates the LDAP user name attribute and updates the
796 json response with the new value.
797 * @param userNameAttribute attribute to be updated.
798 * @param asyncResp pointer to the JSON response
799 * @param ldapServerElementName Type of LDAP
800 server(openLDAP/ActiveDirectory)
801 */
802
803 void handleUserNameAttrPatch(const std::string& userNameAttribute,
804 const std::shared_ptr<AsyncResp>& asyncResp,
805 const std::string& ldapServerElementName,
806 const std::string& ldapConfigObject)
807 {
808 crow::connections::systemBus->async_method_call(
809 [asyncResp, userNameAttribute,
810 ldapServerElementName](const boost::system::error_code ec) {
811 if (ec)
812 {
Gunnar Millsc61704a2020-07-08 13:47:06 -0500813 BMCWEB_LOG_DEBUG << "Error Occurred in Updating the "
Ratan Gupta8a07d282019-03-16 08:33:47 +0530814 "username attribute";
815 messages::internalError(asyncResp->res);
816 return;
817 }
818 auto& serverTypeJson =
819 asyncResp->res.jsonValue[ldapServerElementName];
820 auto& searchSettingsJson =
821 serverTypeJson["LDAPService"]["SearchSettings"];
822 searchSettingsJson["UsernameAttribute"] = userNameAttribute;
823 BMCWEB_LOG_DEBUG << "Updated the user name attr.";
824 },
825 ldapDbusService, ldapConfigObject, propertyInterface, "Set",
826 ldapConfigInterface, "UserNameAttribute",
827 std::variant<std::string>(userNameAttribute));
828 }
829 /**
830 * @brief updates the LDAP group attribute and updates the
831 json response with the new value.
832 * @param groupsAttribute attribute to be updated.
833 * @param asyncResp pointer to the JSON response
834 * @param ldapServerElementName Type of LDAP
835 server(openLDAP/ActiveDirectory)
836 */
837
838 void handleGroupNameAttrPatch(const std::string& groupsAttribute,
839 const std::shared_ptr<AsyncResp>& asyncResp,
840 const std::string& ldapServerElementName,
841 const std::string& ldapConfigObject)
842 {
843 crow::connections::systemBus->async_method_call(
844 [asyncResp, groupsAttribute,
845 ldapServerElementName](const boost::system::error_code ec) {
846 if (ec)
847 {
Gunnar Millsc61704a2020-07-08 13:47:06 -0500848 BMCWEB_LOG_DEBUG << "Error Occurred in Updating the "
Ratan Gupta8a07d282019-03-16 08:33:47 +0530849 "groupname attribute";
850 messages::internalError(asyncResp->res);
851 return;
852 }
853 auto& serverTypeJson =
854 asyncResp->res.jsonValue[ldapServerElementName];
855 auto& searchSettingsJson =
856 serverTypeJson["LDAPService"]["SearchSettings"];
857 searchSettingsJson["GroupsAttribute"] = groupsAttribute;
858 BMCWEB_LOG_DEBUG << "Updated the groupname attr";
859 },
860 ldapDbusService, ldapConfigObject, propertyInterface, "Set",
861 ldapConfigInterface, "GroupNameAttribute",
862 std::variant<std::string>(groupsAttribute));
863 }
864 /**
865 * @brief updates the LDAP service enable and updates the
866 json response with the new value.
867 * @param input JSON data.
868 * @param asyncResp pointer to the JSON response
869 * @param ldapServerElementName Type of LDAP
870 server(openLDAP/ActiveDirectory)
871 */
872
873 void handleServiceEnablePatch(bool serviceEnabled,
874 const std::shared_ptr<AsyncResp>& asyncResp,
875 const std::string& ldapServerElementName,
876 const std::string& ldapConfigObject)
877 {
878 crow::connections::systemBus->async_method_call(
879 [asyncResp, serviceEnabled,
880 ldapServerElementName](const boost::system::error_code ec) {
881 if (ec)
882 {
883 BMCWEB_LOG_DEBUG
Gunnar Millsc61704a2020-07-08 13:47:06 -0500884 << "Error Occurred in Updating the service enable";
Ratan Gupta8a07d282019-03-16 08:33:47 +0530885 messages::internalError(asyncResp->res);
886 return;
887 }
888 asyncResp->res
889 .jsonValue[ldapServerElementName]["ServiceEnabled"] =
890 serviceEnabled;
891 BMCWEB_LOG_DEBUG << "Updated Service enable = "
892 << serviceEnabled;
893 },
894 ldapDbusService, ldapConfigObject, propertyInterface, "Set",
895 ldapEnableInterface, "Enabled", std::variant<bool>(serviceEnabled));
896 }
897
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100898 void handleAuthMethodsPatch(nlohmann::json& input,
899 const std::shared_ptr<AsyncResp>& asyncResp)
900 {
901 std::optional<bool> basicAuth;
902 std::optional<bool> cookie;
903 std::optional<bool> sessionToken;
904 std::optional<bool> xToken;
Zbigniew Kurzynski501f1e52019-10-02 11:22:11 +0200905 std::optional<bool> tls;
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100906
907 if (!json_util::readJson(input, asyncResp->res, "BasicAuth", basicAuth,
908 "Cookie", cookie, "SessionToken", sessionToken,
Zbigniew Kurzynski501f1e52019-10-02 11:22:11 +0200909 "XToken", xToken, "TLS", tls))
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100910 {
911 BMCWEB_LOG_ERROR << "Cannot read values from AuthMethod tag";
912 return;
913 }
914
915 // Make a copy of methods configuration
Ed Tanous52cc1122020-07-18 13:51:21 -0700916 persistent_data::AuthConfigMethods authMethodsConfig =
917 persistent_data::SessionStore::getInstance().getAuthMethodsConfig();
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100918
919 if (basicAuth)
920 {
Alan Kuof16f6262020-12-08 19:29:59 +0800921#ifndef BMCWEB_ENABLE_BASIC_AUTHENTICATION
922 messages::actionNotSupported(
923 asyncResp->res, "Setting BasicAuth when basic-auth feature "
924 "is disabled");
925 return;
926#endif
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100927 authMethodsConfig.basic = *basicAuth;
928 }
929
930 if (cookie)
931 {
Alan Kuof16f6262020-12-08 19:29:59 +0800932#ifndef BMCWEB_ENABLE_COOKIE_AUTHENTICATION
933 messages::actionNotSupported(
934 asyncResp->res, "Setting Cookie when cookie-auth feature "
935 "is disabled");
936 return;
937#endif
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100938 authMethodsConfig.cookie = *cookie;
939 }
940
941 if (sessionToken)
942 {
Alan Kuof16f6262020-12-08 19:29:59 +0800943#ifndef BMCWEB_ENABLE_SESSION_AUTHENTICATION
944 messages::actionNotSupported(
945 asyncResp->res,
946 "Setting SessionToken when session-auth feature "
947 "is disabled");
948 return;
949#endif
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100950 authMethodsConfig.sessionToken = *sessionToken;
951 }
952
953 if (xToken)
954 {
Alan Kuof16f6262020-12-08 19:29:59 +0800955#ifndef BMCWEB_ENABLE_XTOKEN_AUTHENTICATION
956 messages::actionNotSupported(
957 asyncResp->res, "Setting XToken when xtoken-auth feature "
958 "is disabled");
959 return;
960#endif
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100961 authMethodsConfig.xtoken = *xToken;
962 }
963
Zbigniew Kurzynski501f1e52019-10-02 11:22:11 +0200964 if (tls)
965 {
Alan Kuof16f6262020-12-08 19:29:59 +0800966#ifndef BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION
967 messages::actionNotSupported(
968 asyncResp->res, "Setting TLS when mutual-tls-auth feature "
969 "is disabled");
970 return;
971#endif
Zbigniew Kurzynski501f1e52019-10-02 11:22:11 +0200972 authMethodsConfig.tls = *tls;
973 }
974
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100975 if (!authMethodsConfig.basic && !authMethodsConfig.cookie &&
Zbigniew Kurzynski501f1e52019-10-02 11:22:11 +0200976 !authMethodsConfig.sessionToken && !authMethodsConfig.xtoken &&
977 !authMethodsConfig.tls)
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100978 {
979 // Do not allow user to disable everything
980 messages::actionNotSupported(asyncResp->res,
981 "of disabling all available methods");
982 return;
983 }
984
Ed Tanous52cc1122020-07-18 13:51:21 -0700985 persistent_data::SessionStore::getInstance().updateAuthMethodsConfig(
986 authMethodsConfig);
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100987 // Save configuration immediately
Ed Tanous52cc1122020-07-18 13:51:21 -0700988 persistent_data::getConfig().writeData();
Zbigniew Kurzynski78158632019-11-05 12:57:37 +0100989
990 messages::success(asyncResp->res);
991 }
992
Ratan Gupta8a07d282019-03-16 08:33:47 +0530993 /**
994 * @brief Get the required values from the given JSON, validates the
995 * value and create the LDAP config object.
996 * @param input JSON data
997 * @param asyncResp pointer to the JSON response
998 * @param serverType Type of LDAP server(openLDAP/ActiveDirectory)
999 */
1000
1001 void handleLDAPPatch(nlohmann::json& input,
1002 const std::shared_ptr<AsyncResp>& asyncResp,
Ratan Gupta8a07d282019-03-16 08:33:47 +05301003 const std::string& serverType)
1004 {
Ratan Guptaeb2bbe52019-04-22 14:27:01 +05301005 std::string dbusObjectPath;
1006 if (serverType == "ActiveDirectory")
1007 {
Ed Tanous2c70f802020-09-28 14:29:23 -07001008 dbusObjectPath = adConfigObject;
Ratan Guptaeb2bbe52019-04-22 14:27:01 +05301009 }
1010 else if (serverType == "LDAP")
1011 {
Ed Tanous23a21a12020-07-25 04:45:05 +00001012 dbusObjectPath = ldapConfigObjectName;
Ratan Guptaeb2bbe52019-04-22 14:27:01 +05301013 }
Ed Tanouscb13a392020-07-25 19:02:03 +00001014 else
1015 {
1016 return;
1017 }
Ratan Guptaeb2bbe52019-04-22 14:27:01 +05301018
Ratan Gupta8a07d282019-03-16 08:33:47 +05301019 std::optional<nlohmann::json> authentication;
1020 std::optional<nlohmann::json> ldapService;
Ratan Gupta8a07d282019-03-16 08:33:47 +05301021 std::optional<std::vector<std::string>> serviceAddressList;
1022 std::optional<bool> serviceEnabled;
1023 std::optional<std::vector<std::string>> baseDNList;
1024 std::optional<std::string> userNameAttribute;
1025 std::optional<std::string> groupsAttribute;
1026 std::optional<std::string> userName;
1027 std::optional<std::string> password;
Ratan Gupta06785242019-07-26 22:30:16 +05301028 std::optional<std::vector<nlohmann::json>> remoteRoleMapData;
Ratan Gupta8a07d282019-03-16 08:33:47 +05301029
1030 if (!json_util::readJson(input, asyncResp->res, "Authentication",
1031 authentication, "LDAPService", ldapService,
1032 "ServiceAddresses", serviceAddressList,
Ratan Gupta06785242019-07-26 22:30:16 +05301033 "ServiceEnabled", serviceEnabled,
1034 "RemoteRoleMapping", remoteRoleMapData))
Ratan Gupta8a07d282019-03-16 08:33:47 +05301035 {
1036 return;
1037 }
1038
1039 if (authentication)
1040 {
1041 parseLDAPAuthenticationJson(*authentication, asyncResp, userName,
1042 password);
1043 }
1044 if (ldapService)
1045 {
1046 parseLDAPServiceJson(*ldapService, asyncResp, baseDNList,
1047 userNameAttribute, groupsAttribute);
1048 }
Ratan Gupta8a07d282019-03-16 08:33:47 +05301049 if (serviceAddressList)
1050 {
1051 if ((*serviceAddressList).size() == 0)
1052 {
1053 messages::propertyValueNotInList(asyncResp->res, "[]",
1054 "ServiceAddress");
1055 return;
1056 }
1057 }
1058 if (baseDNList)
1059 {
1060 if ((*baseDNList).size() == 0)
1061 {
1062 messages::propertyValueNotInList(asyncResp->res, "[]",
1063 "BaseDistinguishedNames");
1064 return;
1065 }
1066 }
1067
1068 // nothing to update, then return
1069 if (!userName && !password && !serviceAddressList && !baseDNList &&
Ratan Gupta06785242019-07-26 22:30:16 +05301070 !userNameAttribute && !groupsAttribute && !serviceEnabled &&
1071 !remoteRoleMapData)
Ratan Gupta8a07d282019-03-16 08:33:47 +05301072 {
1073 return;
1074 }
1075
1076 // Get the existing resource first then keep modifying
1077 // whenever any property gets updated.
Ed Tanousb5a76932020-09-29 16:16:58 -07001078 getLDAPConfigData(
1079 serverType, [this, asyncResp, userName, password, baseDNList,
1080 userNameAttribute, groupsAttribute, serviceAddressList,
1081 serviceEnabled, dbusObjectPath, remoteRoleMapData](
1082 bool success, const LDAPConfigData& confData,
1083 const std::string& serverT) {
1084 if (!success)
Ratan Gupta8a07d282019-03-16 08:33:47 +05301085 {
Ed Tanousb5a76932020-09-29 16:16:58 -07001086 messages::internalError(asyncResp->res);
1087 return;
1088 }
1089 parseLDAPConfigData(asyncResp->res.jsonValue, confData,
1090 serverT);
1091 if (confData.serviceEnabled)
1092 {
1093 // Disable the service first and update the rest of
1094 // the properties.
1095 handleServiceEnablePatch(false, asyncResp, serverT,
1096 dbusObjectPath);
1097 }
1098
1099 if (serviceAddressList)
1100 {
1101 handleServiceAddressPatch(*serviceAddressList, asyncResp,
1102 serverT, dbusObjectPath);
1103 }
1104 if (userName)
1105 {
1106 handleUserNamePatch(*userName, asyncResp, serverT,
1107 dbusObjectPath);
1108 }
1109 if (password)
1110 {
1111 handlePasswordPatch(*password, asyncResp, serverT,
1112 dbusObjectPath);
1113 }
1114
1115 if (baseDNList)
1116 {
1117 handleBaseDNPatch(*baseDNList, asyncResp, serverT,
1118 dbusObjectPath);
1119 }
1120 if (userNameAttribute)
1121 {
1122 handleUserNameAttrPatch(*userNameAttribute, asyncResp,
1123 serverT, dbusObjectPath);
1124 }
1125 if (groupsAttribute)
1126 {
1127 handleGroupNameAttrPatch(*groupsAttribute, asyncResp,
Ed Tanous23a21a12020-07-25 04:45:05 +00001128 serverT, dbusObjectPath);
Ratan Gupta8a07d282019-03-16 08:33:47 +05301129 }
Ed Tanousb5a76932020-09-29 16:16:58 -07001130 if (serviceEnabled)
1131 {
1132 // if user has given the value as true then enable
1133 // the service. if user has given false then no-op
1134 // as service is already stopped.
1135 if (*serviceEnabled)
1136 {
1137 handleServiceEnablePatch(*serviceEnabled, asyncResp,
1138 serverT, dbusObjectPath);
1139 }
1140 }
1141 else
1142 {
1143 // if user has not given the service enabled value
1144 // then revert it to the same state as it was
1145 // before.
1146 handleServiceEnablePatch(confData.serviceEnabled, asyncResp,
1147 serverT, dbusObjectPath);
1148 }
Ratan Gupta06785242019-07-26 22:30:16 +05301149
Ed Tanousb5a76932020-09-29 16:16:58 -07001150 if (remoteRoleMapData)
1151 {
Ed Tanousb5a76932020-09-29 16:16:58 -07001152 handleRoleMapPatch(asyncResp, confData.groupRoleList,
Ed Tanousf23b7292020-10-15 09:41:17 -07001153 serverT, *remoteRoleMapData);
Ed Tanousb5a76932020-09-29 16:16:58 -07001154 }
1155 });
Ratan Gupta8a07d282019-03-16 08:33:47 +05301156 }
Ed Tanousd4b54432019-07-17 22:51:55 +00001157
Ed Tanouscb13a392020-07-25 19:02:03 +00001158 void doGet(crow::Response& res, const crow::Request&,
1159 const std::vector<std::string>&) override
Ed Tanous1abe55e2018-09-05 08:30:59 -07001160 {
Ed Tanous52cc1122020-07-18 13:51:21 -07001161 const persistent_data::AuthConfigMethods& authMethodsConfig =
1162 persistent_data::SessionStore::getInstance().getAuthMethodsConfig();
Zbigniew Kurzynski78158632019-11-05 12:57:37 +01001163
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301164 auto asyncResp = std::make_shared<AsyncResp>(res);
1165 res.jsonValue = {
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301166 {"@odata.id", "/redfish/v1/AccountService"},
1167 {"@odata.type", "#AccountService."
Gunnar Millsba9dd4a2020-02-20 10:40:18 -06001168 "v1_5_0.AccountService"},
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301169 {"Id", "AccountService"},
1170 {"Name", "Account Service"},
1171 {"Description", "Account Service"},
1172 {"ServiceEnabled", true},
AppaRao Puli343ff2e2019-03-24 00:42:13 +05301173 {"MaxPasswordLength", 20},
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301174 {"Accounts",
1175 {{"@odata.id", "/redfish/v1/AccountService/Accounts"}}},
Marri Devender Rao37cce912019-02-20 01:05:22 -06001176 {"Roles", {{"@odata.id", "/redfish/v1/AccountService/Roles"}}},
Zbigniew Kurzynski78158632019-11-05 12:57:37 +01001177 {"Oem",
1178 {{"OpenBMC",
1179 {{"@odata.type", "#OemAccountService.v1_0_0.AccountService"},
1180 {"AuthMethods",
1181 {
1182 {"BasicAuth", authMethodsConfig.basic},
1183 {"SessionToken", authMethodsConfig.sessionToken},
1184 {"XToken", authMethodsConfig.xtoken},
1185 {"Cookie", authMethodsConfig.cookie},
Zbigniew Kurzynski501f1e52019-10-02 11:22:11 +02001186 {"TLS", authMethodsConfig.tls},
Zbigniew Kurzynski78158632019-11-05 12:57:37 +01001187 }}}}}},
Marri Devender Rao37cce912019-02-20 01:05:22 -06001188 {"LDAP",
1189 {{"Certificates",
1190 {{"@odata.id",
1191 "/redfish/v1/AccountService/LDAP/Certificates"}}}}}};
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301192 crow::connections::systemBus->async_method_call(
1193 [asyncResp](
1194 const boost::system::error_code ec,
1195 const std::vector<std::pair<
Ed Tanousabf2add2019-01-22 16:40:12 -08001196 std::string, std::variant<uint32_t, uint16_t, uint8_t>>>&
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301197 propertiesList) {
1198 if (ec)
1199 {
1200 messages::internalError(asyncResp->res);
1201 return;
1202 }
1203 BMCWEB_LOG_DEBUG << "Got " << propertiesList.size()
1204 << "properties for AccountService";
1205 for (const std::pair<std::string,
Ed Tanousabf2add2019-01-22 16:40:12 -08001206 std::variant<uint32_t, uint16_t, uint8_t>>&
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301207 property : propertiesList)
1208 {
1209 if (property.first == "MinPasswordLength")
1210 {
1211 const uint8_t* value =
Ed Tanousabf2add2019-01-22 16:40:12 -08001212 std::get_if<uint8_t>(&property.second);
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301213 if (value != nullptr)
1214 {
1215 asyncResp->res.jsonValue["MinPasswordLength"] =
1216 *value;
1217 }
1218 }
1219 if (property.first == "AccountUnlockTimeout")
1220 {
1221 const uint32_t* value =
Ed Tanousabf2add2019-01-22 16:40:12 -08001222 std::get_if<uint32_t>(&property.second);
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301223 if (value != nullptr)
1224 {
1225 asyncResp->res.jsonValue["AccountLockoutDuration"] =
1226 *value;
1227 }
1228 }
1229 if (property.first == "MaxLoginAttemptBeforeLockout")
1230 {
1231 const uint16_t* value =
Ed Tanousabf2add2019-01-22 16:40:12 -08001232 std::get_if<uint16_t>(&property.second);
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301233 if (value != nullptr)
1234 {
1235 asyncResp->res
1236 .jsonValue["AccountLockoutThreshold"] = *value;
1237 }
1238 }
1239 }
1240 },
1241 "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
1242 "org.freedesktop.DBus.Properties", "GetAll",
1243 "xyz.openbmc_project.User.AccountPolicy");
Ratan Gupta6973a582018-12-13 18:25:44 +05301244
Ratan Guptaab828d72019-04-22 14:18:33 +05301245 auto callback = [asyncResp](bool success, LDAPConfigData& confData,
1246 const std::string& ldapType) {
Ed Tanouscb13a392020-07-25 19:02:03 +00001247 if (!success)
1248 {
1249 return;
1250 }
Ratan Guptaab828d72019-04-22 14:18:33 +05301251 parseLDAPConfigData(asyncResp->res.jsonValue, confData, ldapType);
1252 };
1253
1254 getLDAPConfigData("LDAP", callback);
1255 getLDAPConfigData("ActiveDirectory", callback);
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301256 }
Ratan Gupta6973a582018-12-13 18:25:44 +05301257
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301258 void doPatch(crow::Response& res, const crow::Request& req,
Ed Tanouscb13a392020-07-25 19:02:03 +00001259 const std::vector<std::string>&) override
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301260 {
1261 auto asyncResp = std::make_shared<AsyncResp>(res);
1262
1263 std::optional<uint32_t> unlockTimeout;
1264 std::optional<uint16_t> lockoutThreshold;
Ratan Gupta19fb6e72019-03-04 13:30:50 +05301265 std::optional<uint16_t> minPasswordLength;
1266 std::optional<uint16_t> maxPasswordLength;
Ratan Gupta8a07d282019-03-16 08:33:47 +05301267 std::optional<nlohmann::json> ldapObject;
Ratan Guptaeb2bbe52019-04-22 14:27:01 +05301268 std::optional<nlohmann::json> activeDirectoryObject;
Zbigniew Kurzynski78158632019-11-05 12:57:37 +01001269 std::optional<nlohmann::json> oemObject;
Ratan Gupta19fb6e72019-03-04 13:30:50 +05301270
Zbigniew Kurzynski78158632019-11-05 12:57:37 +01001271 if (!json_util::readJson(
1272 req, res, "AccountLockoutDuration", unlockTimeout,
1273 "AccountLockoutThreshold", lockoutThreshold,
1274 "MaxPasswordLength", maxPasswordLength, "MinPasswordLength",
1275 minPasswordLength, "LDAP", ldapObject, "ActiveDirectory",
1276 activeDirectoryObject, "Oem", oemObject))
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301277 {
1278 return;
1279 }
Ratan Gupta19fb6e72019-03-04 13:30:50 +05301280
1281 if (minPasswordLength)
1282 {
1283 messages::propertyNotWritable(asyncResp->res, "MinPasswordLength");
1284 }
1285
1286 if (maxPasswordLength)
1287 {
1288 messages::propertyNotWritable(asyncResp->res, "MaxPasswordLength");
1289 }
1290
Ratan Gupta8a07d282019-03-16 08:33:47 +05301291 if (ldapObject)
1292 {
Ed Tanouscb13a392020-07-25 19:02:03 +00001293 handleLDAPPatch(*ldapObject, asyncResp, "LDAP");
Ratan Gupta8a07d282019-03-16 08:33:47 +05301294 }
1295
Zbigniew Kurzynski78158632019-11-05 12:57:37 +01001296 if (std::optional<nlohmann::json> oemOpenBMCObject;
1297 oemObject &&
1298 json_util::readJson(*oemObject, res, "OpenBMC", oemOpenBMCObject))
1299 {
1300 if (std::optional<nlohmann::json> authMethodsObject;
1301 oemOpenBMCObject &&
1302 json_util::readJson(*oemOpenBMCObject, res, "AuthMethods",
1303 authMethodsObject))
1304 {
1305 if (authMethodsObject)
1306 {
1307 handleAuthMethodsPatch(*authMethodsObject, asyncResp);
1308 }
1309 }
1310 }
1311
Ratan Guptaeb2bbe52019-04-22 14:27:01 +05301312 if (activeDirectoryObject)
1313 {
Ed Tanouscb13a392020-07-25 19:02:03 +00001314 handleLDAPPatch(*activeDirectoryObject, asyncResp,
Ratan Guptaeb2bbe52019-04-22 14:27:01 +05301315 "ActiveDirectory");
1316 }
1317
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301318 if (unlockTimeout)
1319 {
1320 crow::connections::systemBus->async_method_call(
1321 [asyncResp](const boost::system::error_code ec) {
1322 if (ec)
1323 {
1324 messages::internalError(asyncResp->res);
1325 return;
1326 }
Ratan Guptaadd61332019-02-13 20:49:16 +05301327 messages::success(asyncResp->res);
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301328 },
1329 "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
1330 "org.freedesktop.DBus.Properties", "Set",
1331 "xyz.openbmc_project.User.AccountPolicy",
Ed Tanousabf2add2019-01-22 16:40:12 -08001332 "AccountUnlockTimeout", std::variant<uint32_t>(*unlockTimeout));
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301333 }
1334 if (lockoutThreshold)
1335 {
1336 crow::connections::systemBus->async_method_call(
1337 [asyncResp](const boost::system::error_code ec) {
1338 if (ec)
1339 {
1340 messages::internalError(asyncResp->res);
1341 return;
1342 }
Ratan Guptaadd61332019-02-13 20:49:16 +05301343 messages::success(asyncResp->res);
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301344 },
1345 "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
1346 "org.freedesktop.DBus.Properties", "Set",
1347 "xyz.openbmc_project.User.AccountPolicy",
1348 "MaxLoginAttemptBeforeLockout",
Ed Tanousabf2add2019-01-22 16:40:12 -08001349 std::variant<uint16_t>(*lockoutThreshold));
AppaRao Puli3d958bb2018-12-25 12:45:54 +05301350 }
Ed Tanous1abe55e2018-09-05 08:30:59 -07001351 }
Lewanczyk, Dawid88d16c92018-02-02 14:51:09 +01001352};
Tanousf00032d2018-11-05 01:18:10 -03001353
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001354class AccountsCollection : public Node
1355{
1356 public:
Ed Tanous52cc1122020-07-18 13:51:21 -07001357 AccountsCollection(App& app) :
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001358 Node(app, "/redfish/v1/AccountService/Accounts/")
1359 {
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001360 entityPrivileges = {
Gunnar Millsf3659102020-01-29 16:23:28 -06001361 // According to the PrivilegeRegistry, GET should actually be
1362 // "Login". A "Login" only privilege would return an empty "Members"
1363 // list. Not going to worry about this since none of the defined
1364 // roles are just "Login". E.g. Readonly is {"Login",
1365 // "ConfigureSelf"}. In the rare event anyone defines a role that
1366 // has Login but not ConfigureSelf, implement this.
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001367 {boost::beast::http::verb::get,
Gunnar Millsf3659102020-01-29 16:23:28 -06001368 {{"ConfigureUsers"}, {"ConfigureSelf"}}},
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001369 {boost::beast::http::verb::head, {{"Login"}}},
1370 {boost::beast::http::verb::patch, {{"ConfigureUsers"}}},
1371 {boost::beast::http::verb::put, {{"ConfigureUsers"}}},
1372 {boost::beast::http::verb::delete_, {{"ConfigureUsers"}}},
1373 {boost::beast::http::verb::post, {{"ConfigureUsers"}}}};
1374 }
1375
1376 private:
1377 void doGet(crow::Response& res, const crow::Request& req,
Ed Tanouscb13a392020-07-25 19:02:03 +00001378 const std::vector<std::string>&) override
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001379 {
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001380 auto asyncResp = std::make_shared<AsyncResp>(res);
Gunnar Mills94400962020-02-14 11:56:41 -06001381 res.jsonValue = {{"@odata.id", "/redfish/v1/AccountService/Accounts"},
Ed Tanous0f74e642018-11-12 15:17:05 -08001382 {"@odata.type", "#ManagerAccountCollection."
1383 "ManagerAccountCollection"},
1384 {"Name", "Accounts Collection"},
1385 {"Description", "BMC User Accounts"}};
1386
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001387 crow::connections::systemBus->async_method_call(
Gunnar Millsf3659102020-01-29 16:23:28 -06001388 [asyncResp, &req, this](const boost::system::error_code ec,
1389 const ManagedObjectType& users) {
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001390 if (ec)
1391 {
Jason M. Billsf12894f2018-10-09 12:45:45 -07001392 messages::internalError(asyncResp->res);
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001393 return;
1394 }
1395
1396 nlohmann::json& memberArray =
1397 asyncResp->res.jsonValue["Members"];
1398 memberArray = nlohmann::json::array();
1399
Ed Tanous2dfd18e2020-12-18 00:41:31 +00001400 for (auto& userpath : users)
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001401 {
Ed Tanous2dfd18e2020-12-18 00:41:31 +00001402 std::string user = userpath.first.filename();
1403 if (user.empty())
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001404 {
Ed Tanous2dfd18e2020-12-18 00:41:31 +00001405 messages::internalError(asyncResp->res);
1406 BMCWEB_LOG_ERROR << "Invalid firmware ID";
1407
1408 return;
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001409 }
Gunnar Millsf3659102020-01-29 16:23:28 -06001410
1411 // As clarified by Redfish here:
1412 // https://redfishforum.com/thread/281/manageraccountcollection-change-allows-account-enumeration
1413 // Users without ConfigureUsers, only see their own account.
1414 // Users with ConfigureUsers, see all accounts.
Ed Tanous2dfd18e2020-12-18 00:41:31 +00001415 if (req.session->username == user ||
Gunnar Millsf3659102020-01-29 16:23:28 -06001416 isAllowedWithoutConfigureSelf(req))
1417 {
1418 memberArray.push_back(
1419 {{"@odata.id",
Ed Tanous2dfd18e2020-12-18 00:41:31 +00001420 "/redfish/v1/AccountService/Accounts/" + user}});
Gunnar Millsf3659102020-01-29 16:23:28 -06001421 }
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001422 }
Gunnar Millsf3659102020-01-29 16:23:28 -06001423 asyncResp->res.jsonValue["Members@odata.count"] =
1424 memberArray.size();
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001425 },
1426 "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
1427 "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
1428 }
Ed Tanous04ae99e2018-09-20 15:54:36 -07001429 void doPost(crow::Response& res, const crow::Request& req,
Ed Tanouscb13a392020-07-25 19:02:03 +00001430 const std::vector<std::string>&) override
Ed Tanous04ae99e2018-09-20 15:54:36 -07001431 {
1432 auto asyncResp = std::make_shared<AsyncResp>(res);
1433
Ed Tanous9712f8a2018-09-21 13:38:49 -07001434 std::string username;
1435 std::string password;
Ed Tanousa24526d2018-12-10 15:17:59 -08001436 std::optional<std::string> roleId("User");
1437 std::optional<bool> enabled = true;
Ed Tanous9712f8a2018-09-21 13:38:49 -07001438 if (!json_util::readJson(req, res, "UserName", username, "Password",
1439 password, "RoleId", roleId, "Enabled",
1440 enabled))
Ed Tanous04ae99e2018-09-20 15:54:36 -07001441 {
1442 return;
1443 }
1444
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -06001445 std::string priv = getPrivilegeFromRoleId(*roleId);
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301446 if (priv.empty())
Ed Tanous04ae99e2018-09-20 15:54:36 -07001447 {
Jason M. Billsf12894f2018-10-09 12:45:45 -07001448 messages::propertyValueNotInList(asyncResp->res, *roleId, "RoleId");
Ed Tanous04ae99e2018-09-20 15:54:36 -07001449 return;
1450 }
jayaprakash Mutyala96200602020-04-08 11:09:10 +00001451 // TODO: Following override will be reverted once support in
1452 // phosphor-user-manager is added. In order to avoid dependency issues,
1453 // this is added in bmcweb, which will removed, once
1454 // phosphor-user-manager supports priv-noaccess.
1455 if (priv == "priv-noaccess")
1456 {
1457 roleId = "";
1458 }
1459 else
1460 {
1461 roleId = priv;
1462 }
Ed Tanous04ae99e2018-09-20 15:54:36 -07001463
Ayushi Smriti599c71d2019-08-23 17:43:18 +00001464 // Reading AllGroups property
Ed Tanous04ae99e2018-09-20 15:54:36 -07001465 crow::connections::systemBus->async_method_call(
Ayushi Smriti599c71d2019-08-23 17:43:18 +00001466 [asyncResp, username, password{std::move(password)}, roleId,
1467 enabled](const boost::system::error_code ec,
1468 const std::variant<std::vector<std::string>>& allGroups) {
Ed Tanous04ae99e2018-09-20 15:54:36 -07001469 if (ec)
1470 {
Ayushi Smriti599c71d2019-08-23 17:43:18 +00001471 BMCWEB_LOG_DEBUG << "ERROR with async_method_call";
1472 messages::internalError(asyncResp->res);
Ed Tanous04ae99e2018-09-20 15:54:36 -07001473 return;
1474 }
1475
Ayushi Smriti599c71d2019-08-23 17:43:18 +00001476 const std::vector<std::string>* allGroupsList =
1477 std::get_if<std::vector<std::string>>(&allGroups);
1478
1479 if (allGroupsList == nullptr || allGroupsList->empty())
Ed Tanous04ae99e2018-09-20 15:54:36 -07001480 {
Ayushi Smriti599c71d2019-08-23 17:43:18 +00001481 messages::internalError(asyncResp->res);
Ed Tanous04ae99e2018-09-20 15:54:36 -07001482 return;
1483 }
1484
Ayushi Smriti599c71d2019-08-23 17:43:18 +00001485 crow::connections::systemBus->async_method_call(
Ed Tanousf23b7292020-10-15 09:41:17 -07001486 [asyncResp, username,
1487 password](const boost::system::error_code ec2,
1488 sdbusplus::message::message& m) {
Ed Tanous23a21a12020-07-25 04:45:05 +00001489 if (ec2)
Ayushi Smriti599c71d2019-08-23 17:43:18 +00001490 {
anil kumar appana0d4197e2019-06-13 15:06:23 +00001491 userErrorMessageHandler(m.get_error(), asyncResp,
1492 username, "");
Ayushi Smriti599c71d2019-08-23 17:43:18 +00001493 return;
1494 }
1495
jayaprakash Mutyala66b5ca72019-08-07 20:26:37 +00001496 if (pamUpdatePassword(username, password) !=
1497 PAM_SUCCESS)
Ayushi Smriti599c71d2019-08-23 17:43:18 +00001498 {
1499 // At this point we have a user that's been created,
1500 // but the password set failed.Something is wrong,
1501 // so delete the user that we've already created
1502 crow::connections::systemBus->async_method_call(
Ed Tanous23a21a12020-07-25 04:45:05 +00001503 [asyncResp, password](
1504 const boost::system::error_code ec3) {
1505 if (ec3)
Ayushi Smriti599c71d2019-08-23 17:43:18 +00001506 {
1507 messages::internalError(asyncResp->res);
1508 return;
1509 }
1510
anil kumar appana0d4197e2019-06-13 15:06:23 +00001511 // If password is invalid
1512 messages::propertyValueFormatError(
1513 asyncResp->res, password, "Password");
Ayushi Smriti599c71d2019-08-23 17:43:18 +00001514 },
1515 "xyz.openbmc_project.User.Manager",
1516 "/xyz/openbmc_project/user/" + username,
1517 "xyz.openbmc_project.Object.Delete", "Delete");
1518
1519 BMCWEB_LOG_ERROR << "pamUpdatePassword Failed";
1520 return;
1521 }
1522
1523 messages::created(asyncResp->res);
1524 asyncResp->res.addHeader(
1525 "Location",
1526 "/redfish/v1/AccountService/Accounts/" + username);
1527 },
1528 "xyz.openbmc_project.User.Manager",
1529 "/xyz/openbmc_project/user",
1530 "xyz.openbmc_project.User.Manager", "CreateUser", username,
1531 *allGroupsList, *roleId, *enabled);
Ed Tanous04ae99e2018-09-20 15:54:36 -07001532 },
1533 "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
Ayushi Smriti599c71d2019-08-23 17:43:18 +00001534 "org.freedesktop.DBus.Properties", "Get",
1535 "xyz.openbmc_project.User.Manager", "AllGroups");
Ed Tanous04ae99e2018-09-20 15:54:36 -07001536 }
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001537};
1538
1539class ManagerAccount : public Node
1540{
1541 public:
Ed Tanous52cc1122020-07-18 13:51:21 -07001542 ManagerAccount(App& app) :
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001543 Node(app, "/redfish/v1/AccountService/Accounts/<str>/", std::string())
1544 {
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001545 entityPrivileges = {
1546 {boost::beast::http::verb::get,
1547 {{"ConfigureUsers"}, {"ConfigureManager"}, {"ConfigureSelf"}}},
1548 {boost::beast::http::verb::head, {{"Login"}}},
Joseph Reynolds900f9492019-11-25 15:37:29 -06001549 {boost::beast::http::verb::patch,
1550 {{"ConfigureUsers"}, {"ConfigureSelf"}}},
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001551 {boost::beast::http::verb::put, {{"ConfigureUsers"}}},
1552 {boost::beast::http::verb::delete_, {{"ConfigureUsers"}}},
1553 {boost::beast::http::verb::post, {{"ConfigureUsers"}}}};
1554 }
1555
1556 private:
1557 void doGet(crow::Response& res, const crow::Request& req,
1558 const std::vector<std::string>& params) override
1559 {
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001560 auto asyncResp = std::make_shared<AsyncResp>(res);
1561
1562 if (params.size() != 1)
1563 {
Jason M. Billsf12894f2018-10-09 12:45:45 -07001564 messages::internalError(asyncResp->res);
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001565 return;
1566 }
1567
Joseph Reynolds900f9492019-11-25 15:37:29 -06001568 // Perform a proper ConfigureSelf authority check. If the
1569 // user is operating on an account not their own, then their
1570 // ConfigureSelf privilege does not apply. In this case,
1571 // perform the authority check again without the user's
1572 // ConfigureSelf privilege.
1573 if (req.session->username != params[0])
1574 {
1575 if (!isAllowedWithoutConfigureSelf(req))
1576 {
1577 BMCWEB_LOG_DEBUG << "GET Account denied access";
1578 messages::insufficientPrivilege(asyncResp->res);
1579 return;
1580 }
1581 }
1582
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001583 crow::connections::systemBus->async_method_call(
1584 [asyncResp, accountName{std::string(params[0])}](
1585 const boost::system::error_code ec,
1586 const ManagedObjectType& users) {
1587 if (ec)
1588 {
Jason M. Billsf12894f2018-10-09 12:45:45 -07001589 messages::internalError(asyncResp->res);
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001590 return;
1591 }
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301592 auto userIt = users.begin();
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001593
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301594 for (; userIt != users.end(); userIt++)
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001595 {
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301596 if (boost::ends_with(userIt->first.str, "/" + accountName))
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001597 {
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301598 break;
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001599 }
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301600 }
1601 if (userIt == users.end())
1602 {
1603 messages::resourceNotFound(asyncResp->res, "ManagerAccount",
1604 accountName);
1605 return;
1606 }
Ayushi Smriti4e68c452019-09-04 14:37:55 +05301607
1608 asyncResp->res.jsonValue = {
Gunnar Mills8114bd42020-06-11 20:55:21 -05001609 {"@odata.type", "#ManagerAccount.v1_4_0.ManagerAccount"},
Ayushi Smriti4e68c452019-09-04 14:37:55 +05301610 {"Name", "User Account"},
1611 {"Description", "User Account"},
Gunnar Mills8114bd42020-06-11 20:55:21 -05001612 {"Password", nullptr},
1613 {"AccountTypes", {"Redfish"}}};
Ayushi Smriti4e68c452019-09-04 14:37:55 +05301614
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301615 for (const auto& interface : userIt->second)
1616 {
1617 if (interface.first ==
1618 "xyz.openbmc_project.User.Attributes")
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001619 {
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301620 for (const auto& property : interface.second)
Ed Tanous65b0dc32018-09-19 16:04:03 -07001621 {
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301622 if (property.first == "UserEnabled")
Ed Tanous65b0dc32018-09-19 16:04:03 -07001623 {
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301624 const bool* userEnabled =
Ed Tanousabf2add2019-01-22 16:40:12 -08001625 std::get_if<bool>(&property.second);
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301626 if (userEnabled == nullptr)
Ed Tanous65b0dc32018-09-19 16:04:03 -07001627 {
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301628 BMCWEB_LOG_ERROR
1629 << "UserEnabled wasn't a bool";
1630 messages::internalError(asyncResp->res);
1631 return;
Ed Tanous65b0dc32018-09-19 16:04:03 -07001632 }
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301633 asyncResp->res.jsonValue["Enabled"] =
1634 *userEnabled;
1635 }
1636 else if (property.first ==
1637 "UserLockedForFailedAttempt")
1638 {
1639 const bool* userLocked =
Ed Tanousabf2add2019-01-22 16:40:12 -08001640 std::get_if<bool>(&property.second);
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301641 if (userLocked == nullptr)
1642 {
1643 BMCWEB_LOG_ERROR << "UserLockedForF"
1644 "ailedAttempt "
1645 "wasn't a bool";
1646 messages::internalError(asyncResp->res);
1647 return;
1648 }
1649 asyncResp->res.jsonValue["Locked"] =
1650 *userLocked;
Ratan Gupta24c85422019-01-30 19:41:24 +05301651 asyncResp->res.jsonValue
1652 ["Locked@Redfish.AllowableValues"] = {
Joseph Reynolds3bf4e632020-02-06 14:44:32 -06001653 "false"}; // can only unlock accounts
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301654 }
1655 else if (property.first == "UserPrivilege")
1656 {
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -06001657 const std::string* userPrivPtr =
Ed Tanousabf2add2019-01-22 16:40:12 -08001658 std::get_if<std::string>(&property.second);
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -06001659 if (userPrivPtr == nullptr)
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301660 {
1661 BMCWEB_LOG_ERROR
1662 << "UserPrivilege wasn't a "
1663 "string";
1664 messages::internalError(asyncResp->res);
1665 return;
1666 }
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -06001667 std::string role =
1668 getRoleIdFromPrivilege(*userPrivPtr);
1669 if (role.empty())
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301670 {
1671 BMCWEB_LOG_ERROR << "Invalid user role";
1672 messages::internalError(asyncResp->res);
1673 return;
1674 }
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -06001675 asyncResp->res.jsonValue["RoleId"] = role;
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301676
1677 asyncResp->res.jsonValue["Links"]["Role"] = {
1678 {"@odata.id", "/redfish/v1/AccountService/"
1679 "Roles/" +
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -06001680 role}};
Ed Tanous65b0dc32018-09-19 16:04:03 -07001681 }
Joseph Reynolds3bf4e632020-02-06 14:44:32 -06001682 else if (property.first == "UserPasswordExpired")
1683 {
1684 const bool* userPasswordExpired =
1685 std::get_if<bool>(&property.second);
1686 if (userPasswordExpired == nullptr)
1687 {
1688 BMCWEB_LOG_ERROR << "UserPassword"
1689 "Expired "
1690 "wasn't a bool";
1691 messages::internalError(asyncResp->res);
1692 return;
1693 }
1694 asyncResp->res
1695 .jsonValue["PasswordChangeRequired"] =
1696 *userPasswordExpired;
1697 }
Ed Tanous65b0dc32018-09-19 16:04:03 -07001698 }
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001699 }
1700 }
1701
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301702 asyncResp->res.jsonValue["@odata.id"] =
1703 "/redfish/v1/AccountService/Accounts/" + accountName;
1704 asyncResp->res.jsonValue["Id"] = accountName;
1705 asyncResp->res.jsonValue["UserName"] = accountName;
Ed Tanousb9b2e0b2018-09-13 13:47:50 -07001706 },
1707 "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
1708 "org.freedesktop.DBus.ObjectManager", "GetManagedObjects");
1709 }
Ed Tanousa8408792018-09-05 16:08:38 -07001710
1711 void doPatch(crow::Response& res, const crow::Request& req,
1712 const std::vector<std::string>& params) override
1713 {
1714 auto asyncResp = std::make_shared<AsyncResp>(res);
Ed Tanousa8408792018-09-05 16:08:38 -07001715 if (params.size() != 1)
1716 {
Jason M. Billsf12894f2018-10-09 12:45:45 -07001717 messages::internalError(asyncResp->res);
Ed Tanousa8408792018-09-05 16:08:38 -07001718 return;
1719 }
1720
Ed Tanousa24526d2018-12-10 15:17:59 -08001721 std::optional<std::string> newUserName;
1722 std::optional<std::string> password;
1723 std::optional<bool> enabled;
1724 std::optional<std::string> roleId;
Ratan Gupta24c85422019-01-30 19:41:24 +05301725 std::optional<bool> locked;
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301726 if (!json_util::readJson(req, res, "UserName", newUserName, "Password",
Ratan Gupta24c85422019-01-30 19:41:24 +05301727 password, "RoleId", roleId, "Enabled", enabled,
1728 "Locked", locked))
Ed Tanousa8408792018-09-05 16:08:38 -07001729 {
1730 return;
1731 }
1732
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301733 const std::string& username = params[0];
Ed Tanousa8408792018-09-05 16:08:38 -07001734
Joseph Reynolds900f9492019-11-25 15:37:29 -06001735 // Perform a proper ConfigureSelf authority check. If the
1736 // session is being used to PATCH a property other than
1737 // Password, then the ConfigureSelf privilege does not apply.
1738 // If the user is operating on an account not their own, then
1739 // their ConfigureSelf privilege does not apply. In either
1740 // case, perform the authority check again without the user's
1741 // ConfigureSelf privilege.
1742 if ((username != req.session->username) ||
1743 (newUserName || enabled || roleId || locked))
1744 {
1745 if (!isAllowedWithoutConfigureSelf(req))
1746 {
1747 BMCWEB_LOG_WARNING << "PATCH Password denied access";
1748 asyncResp->res.clear();
1749 messages::insufficientPrivilege(asyncResp->res);
1750 return;
1751 }
1752 }
1753
jayaprakash Mutyala66b5ca72019-08-07 20:26:37 +00001754 // if user name is not provided in the patch method or if it
1755 // matches the user name in the URI, then we are treating it as updating
1756 // user properties other then username. If username provided doesn't
1757 // match the URI, then we are treating this as user rename request.
1758 if (!newUserName || (newUserName.value() == username))
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301759 {
Ratan Gupta24c85422019-01-30 19:41:24 +05301760 updateUserProperties(asyncResp, username, password, enabled, roleId,
1761 locked);
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301762 return;
1763 }
Ed Tanous3174e4d2020-10-07 11:41:22 -07001764 crow::connections::systemBus->async_method_call(
1765 [this, asyncResp, username, password(std::move(password)),
Ed Tanousf23b7292020-10-15 09:41:17 -07001766 roleId(std::move(roleId)), enabled,
Ed Tanous3174e4d2020-10-07 11:41:22 -07001767 newUser{std::string(*newUserName)},
Ed Tanousf23b7292020-10-15 09:41:17 -07001768 locked](const boost::system::error_code ec,
1769 sdbusplus::message::message& m) {
Ed Tanous3174e4d2020-10-07 11:41:22 -07001770 if (ec)
1771 {
1772 userErrorMessageHandler(m.get_error(), asyncResp, newUser,
1773 username);
1774 return;
1775 }
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301776
Ed Tanous3174e4d2020-10-07 11:41:22 -07001777 updateUserProperties(asyncResp, newUser, password, enabled,
1778 roleId, locked);
1779 },
1780 "xyz.openbmc_project.User.Manager", "/xyz/openbmc_project/user",
1781 "xyz.openbmc_project.User.Manager", "RenameUser", username,
1782 *newUserName);
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301783 }
1784
1785 void updateUserProperties(std::shared_ptr<AsyncResp> asyncResp,
1786 const std::string& username,
Ed Tanousa24526d2018-12-10 15:17:59 -08001787 std::optional<std::string> password,
1788 std::optional<bool> enabled,
Ratan Gupta24c85422019-01-30 19:41:24 +05301789 std::optional<std::string> roleId,
1790 std::optional<bool> locked)
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301791 {
Ratan Gupta24c85422019-01-30 19:41:24 +05301792 std::string dbusObjectPath = "/xyz/openbmc_project/user/" + username;
1793 dbus::utility::escapePathForDbus(dbusObjectPath);
1794
Ratan Gupta22c33712019-05-03 21:50:28 +05301795 dbus::utility::checkDbusPathExists(
Ratan Gupta24c85422019-01-30 19:41:24 +05301796 dbusObjectPath,
1797 [dbusObjectPath(std::move(dbusObjectPath)), username,
Ed Tanousf23b7292020-10-15 09:41:17 -07001798 password(std::move(password)), roleId(std::move(roleId)), enabled,
1799 locked, asyncResp{std::move(asyncResp)}](int rc) {
Ratan Gupta24c85422019-01-30 19:41:24 +05301800 if (!rc)
1801 {
jayaprakash Mutyala66b5ca72019-08-07 20:26:37 +00001802 messages::resourceNotFound(
Gunnar Mills8114bd42020-06-11 20:55:21 -05001803 asyncResp->res, "#ManagerAccount.v1_4_0.ManagerAccount",
jayaprakash Mutyala66b5ca72019-08-07 20:26:37 +00001804 username);
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301805 return;
Ratan Gupta24c85422019-01-30 19:41:24 +05301806 }
jayaprakash Mutyala66b5ca72019-08-07 20:26:37 +00001807
1808 if (password)
1809 {
1810 int retval = pamUpdatePassword(username, *password);
1811
1812 if (retval == PAM_USER_UNKNOWN)
1813 {
1814 messages::resourceNotFound(
1815 asyncResp->res,
Gunnar Mills8114bd42020-06-11 20:55:21 -05001816 "#ManagerAccount.v1_4_0.ManagerAccount", username);
jayaprakash Mutyala66b5ca72019-08-07 20:26:37 +00001817 }
1818 else if (retval == PAM_AUTHTOK_ERR)
1819 {
1820 // If password is invalid
1821 messages::propertyValueFormatError(
1822 asyncResp->res, *password, "Password");
1823 BMCWEB_LOG_ERROR << "pamUpdatePassword Failed";
1824 }
1825 else if (retval != PAM_SUCCESS)
1826 {
1827 messages::internalError(asyncResp->res);
1828 return;
1829 }
1830 }
1831
Ratan Gupta24c85422019-01-30 19:41:24 +05301832 if (enabled)
1833 {
1834 crow::connections::systemBus->async_method_call(
1835 [asyncResp](const boost::system::error_code ec) {
1836 if (ec)
1837 {
1838 BMCWEB_LOG_ERROR << "D-Bus responses error: "
1839 << ec;
1840 messages::internalError(asyncResp->res);
1841 return;
1842 }
1843 messages::success(asyncResp->res);
1844 return;
1845 },
1846 "xyz.openbmc_project.User.Manager",
1847 dbusObjectPath.c_str(),
1848 "org.freedesktop.DBus.Properties", "Set",
1849 "xyz.openbmc_project.User.Attributes", "UserEnabled",
1850 std::variant<bool>{*enabled});
1851 }
Ed Tanous9712f8a2018-09-21 13:38:49 -07001852
Ratan Gupta24c85422019-01-30 19:41:24 +05301853 if (roleId)
1854 {
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -06001855 std::string priv = getPrivilegeFromRoleId(*roleId);
Ratan Gupta24c85422019-01-30 19:41:24 +05301856 if (priv.empty())
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301857 {
Ratan Gupta24c85422019-01-30 19:41:24 +05301858 messages::propertyValueNotInList(asyncResp->res,
1859 *roleId, "RoleId");
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301860 return;
1861 }
jayaprakash Mutyala96200602020-04-08 11:09:10 +00001862 if (priv == "priv-noaccess")
1863 {
1864 priv = "";
1865 }
Ratan Gupta24c85422019-01-30 19:41:24 +05301866
1867 crow::connections::systemBus->async_method_call(
1868 [asyncResp](const boost::system::error_code ec) {
1869 if (ec)
1870 {
1871 BMCWEB_LOG_ERROR << "D-Bus responses error: "
1872 << ec;
1873 messages::internalError(asyncResp->res);
1874 return;
1875 }
1876 messages::success(asyncResp->res);
1877 },
1878 "xyz.openbmc_project.User.Manager",
1879 dbusObjectPath.c_str(),
1880 "org.freedesktop.DBus.Properties", "Set",
1881 "xyz.openbmc_project.User.Attributes", "UserPrivilege",
1882 std::variant<std::string>{priv});
1883 }
1884
1885 if (locked)
1886 {
1887 // admin can unlock the account which is locked by
Nagaraju Goruganti54fc5872019-01-30 05:11:00 -06001888 // successive authentication failures but admin should
1889 // not be allowed to lock an account.
Ratan Gupta24c85422019-01-30 19:41:24 +05301890 if (*locked)
1891 {
1892 messages::propertyValueNotInList(asyncResp->res, "true",
1893 "Locked");
1894 return;
1895 }
1896
1897 crow::connections::systemBus->async_method_call(
1898 [asyncResp](const boost::system::error_code ec) {
1899 if (ec)
1900 {
1901 BMCWEB_LOG_ERROR << "D-Bus responses error: "
1902 << ec;
1903 messages::internalError(asyncResp->res);
1904 return;
1905 }
1906 messages::success(asyncResp->res);
1907 return;
1908 },
1909 "xyz.openbmc_project.User.Manager",
1910 dbusObjectPath.c_str(),
1911 "org.freedesktop.DBus.Properties", "Set",
1912 "xyz.openbmc_project.User.Attributes",
1913 "UserLockedForFailedAttempt",
Patrick Williams19bd78d2020-05-13 17:38:24 -05001914 std::variant<bool>{*locked});
Ratan Gupta24c85422019-01-30 19:41:24 +05301915 }
1916 });
Ed Tanousa8408792018-09-05 16:08:38 -07001917 }
Ed Tanous06e086d2018-09-19 17:19:52 -07001918
Ed Tanouscb13a392020-07-25 19:02:03 +00001919 void doDelete(crow::Response& res, const crow::Request&,
Ed Tanous06e086d2018-09-19 17:19:52 -07001920 const std::vector<std::string>& params) override
1921 {
1922 auto asyncResp = std::make_shared<AsyncResp>(res);
1923
1924 if (params.size() != 1)
1925 {
Jason M. Billsf12894f2018-10-09 12:45:45 -07001926 messages::internalError(asyncResp->res);
Ed Tanous06e086d2018-09-19 17:19:52 -07001927 return;
1928 }
1929
1930 const std::string userPath = "/xyz/openbmc_project/user/" + params[0];
1931
1932 crow::connections::systemBus->async_method_call(
Ed Tanousf23b7292020-10-15 09:41:17 -07001933 [asyncResp,
1934 username{params[0]}](const boost::system::error_code ec) {
Ed Tanous06e086d2018-09-19 17:19:52 -07001935 if (ec)
1936 {
Jason M. Billsf12894f2018-10-09 12:45:45 -07001937 messages::resourceNotFound(
Gunnar Mills8114bd42020-06-11 20:55:21 -05001938 asyncResp->res, "#ManagerAccount.v1_4_0.ManagerAccount",
Jason M. Billsf12894f2018-10-09 12:45:45 -07001939 username);
Ed Tanous06e086d2018-09-19 17:19:52 -07001940 return;
1941 }
1942
Jason M. Billsf12894f2018-10-09 12:45:45 -07001943 messages::accountRemoved(asyncResp->res);
Ed Tanous06e086d2018-09-19 17:19:52 -07001944 },
1945 "xyz.openbmc_project.User.Manager", userPath,
1946 "xyz.openbmc_project.Object.Delete", "Delete");
1947 }
AppaRao Puli84e12cb2018-10-11 01:28:15 +05301948};
Lewanczyk, Dawid88d16c92018-02-02 14:51:09 +01001949
Ed Tanous1abe55e2018-09-05 08:30:59 -07001950} // namespace redfish