Borawski.Lukasz | 86e1b66 | 2018-01-19 14:22:14 +0100 | [diff] [blame] | 1 | /* |
| 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 |
| 17 | |
| 18 | namespace redfish { |
| 19 | |
| 20 | /** |
| 21 | * @brief Class used to store privileges for a given user. |
| 22 | */ |
| 23 | class UserPrivileges { |
| 24 | // TODO: Temporary stub, implementation will come with next patch-sets |
| 25 | private: |
| 26 | uint32_t redfishPrivileges; |
| 27 | uint32_t oemPrivileges; |
| 28 | }; |
| 29 | |
| 30 | /** |
| 31 | * @brief Class used to store privileges for a given Redfish entity. |
| 32 | */ |
| 33 | class EntityPrivileges { |
| 34 | // TODO: Temporary stub, implementation will come with next patch-sets |
| 35 | public: |
| 36 | bool isMethodAllowed(const crow::HTTPMethod& method, |
| 37 | const std::string& username) const { |
| 38 | return true; |
| 39 | } |
| 40 | }; |
| 41 | |
| 42 | /** |
| 43 | * @brief Class used to: |
| 44 | * - read the PrivilegeRegistry file, |
| 45 | * - provide EntityPrivileges objects to callers. |
| 46 | * |
| 47 | * To save runtime memory object of this class should |
| 48 | * exist only for the time required to install all Nodes. |
| 49 | */ |
| 50 | class PrivilegeProvider { |
| 51 | // TODO: Temporary stub, implementation will come with next patch-sets |
| 52 | public: |
| 53 | PrivilegeProvider() { |
| 54 | // load privilege_registry.json to memory |
| 55 | } |
| 56 | |
Borawski.Lukasz | b6df6dc | 2018-01-24 10:20:45 +0100 | [diff] [blame] | 57 | EntityPrivileges getPrivileges(const std::string& entity_url, |
| 58 | const std::string& entity_type) const { |
Borawski.Lukasz | 86e1b66 | 2018-01-19 14:22:14 +0100 | [diff] [blame] | 59 | // return an entity privilege object based on the privilege_registry.json, |
| 60 | // currently returning default constructed object |
| 61 | return EntityPrivileges(); |
| 62 | } |
| 63 | }; |
| 64 | |
| 65 | } // namespace redfish |
| 66 | |