diff options
| author | Ratan Gupta <ratagupt@linux.vnet.ibm.com> | 2019-04-03 10:39:08 +0530 |
|---|---|---|
| committer | Ed Tanous <ed.tanous@intel.com> | 2019-07-11 01:29:29 +0000 |
| commit | 6f3595683739a6528e98b38cc82afbc60f9fda34 (patch) | |
| tree | 36d0636a6d7e6d890fc540fa3e3fd7ab48631318 /redfish-core/include | |
| parent | f5c9f8bda365b90c978a95738b66419ad21df27f (diff) | |
| download | bmcweb-6f3595683739a6528e98b38cc82afbc60f9fda34.tar.gz bmcweb-6f3595683739a6528e98b38cc82afbc60f9fda34.zip | |
Redfish(Authorization): Map the user role with the Redfish privileges
This commit gets the role of the user from the session object and
map it with the redfish privileges and then allow/reject the asked
operation depending on the userprivileges and the entity privileges.
Change-Id: I40be06c28e80b47fe76891cacf863f8495bace88
Signed-off-by: Ratan Gupta <ratagupt@linux.vnet.ibm.com>
Diffstat (limited to 'redfish-core/include')
| -rw-r--r-- | redfish-core/include/privileges.hpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/redfish-core/include/privileges.hpp b/redfish-core/include/privileges.hpp index ca44551..ec6e6a5 100644 --- a/redfish-core/include/privileges.hpp +++ b/redfish-core/include/privileges.hpp @@ -177,6 +177,29 @@ class Privileges std::bitset<maxPrivilegeCount> privilegeBitset = 0; }; +inline const Privileges& getUserPrivileges(const std::string& userRole) +{ + // Redfish privilege : Administrator + if (userRole == "priv-admin") + { + static Privileges admin{"Login", "ConfigureManager", "ConfigureSelf", + "ConfigureUsers", "ConfigureComponents"}; + return admin; + } + else if (userRole == "priv-operator") + { + // Redfish privilege : Operator + static Privileges op{"Login", "ConfigureSelf", "ConfigureComponents"}; + return op; + } + else + { + // Redfish privilege : Readonly + static Privileges readOnly{"Login", "ConfigureSelf"}; + return readOnly; + } +} + using OperationMap = boost::container::flat_map<boost::beast::http::verb, std::vector<Privileges>>; |

