| #ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_AUTHZ_SUBORDINATE_OVERRIDE_H_ |
| #define THIRD_PARTY_MILOTIC_EXTERNAL_CC_AUTHZ_SUBORDINATE_OVERRIDE_H_ |
| |
| #include <string> |
| #include <vector> |
| |
| #include "absl/container/flat_hash_map.h" |
| #include "absl/strings/string_view.h" |
| #include "authorizer_enums.h" |
| #include "override.h" |
| #include "redfish_entity_trie.h" |
| #include "redfish_privileges.h" |
| |
| namespace milotic::authz { |
| |
| /* |
| SubordinateOverride is a special type of override that checks whether the |
| request's uri is a subordinate of the target list. |
| |
| Example: Imagine this below is part of the Ethernet entity mapping |
| "SubordinateOverride": { |
| "Targets": [ |
| "Manager", |
| "EthernetInterfaceCollection", |
| ], |
| "OperationMap": { |
| ... |
| } |
| } |
| |
| This subordinate override above only applies to URIs who have a parent entity |
| type of EthernetInterfaceCollection and a grandparent entity type of Manager. |
| */ |
| class SubordinateOverride : public Override { |
| public: |
| SubordinateOverride( |
| const std::vector<std::string>& targets, |
| const absl::flat_hash_map<ecclesia::Operation, |
| std::vector<RedfishPrivileges>>& operation_map, |
| RedfishEntityTrie& trie) |
| : Override(targets, operation_map), redfish_entity_trie_(trie) {} |
| |
| bool IsApplicable(absl::string_view uri, |
| ecclesia::Operation operation) const override; |
| Override::Type GetOverrideType() const override; |
| |
| private: |
| RedfishEntityTrie& redfish_entity_trie_; |
| }; |
| |
| } // namespace milotic::authz |
| |
| #endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_AUTHZ_SUBORDINATE_OVERRIDE_H_ |