| #ifndef THIRD_PARTY_MILOTIC_EXTERNAL_CC_AUTHZ_REDFISH_AUTHORIZER_INTERFACE_H_ |
| #define THIRD_PARTY_MILOTIC_EXTERNAL_CC_AUTHZ_REDFISH_AUTHORIZER_INTERFACE_H_ |
| |
| #include <cstdint> |
| #include <string> |
| #include <string_view> |
| |
| #include "authorizer_enums.h" |
| #include "peer_identity.h" |
| #include "redfish_privileges.h" |
| |
| namespace milotic::authz { |
| |
| // The Redfish authorization decision API. It answers authorization questions |
| // ("is this peer authorized to perform this operation on this resource?") and |
| // exposes the per-role attributes consumers need to gate access to streaming |
| // telemetry (the peer's role and its sample rate limit). |
| // |
| // This interface is intentionally free of any dependency on nlohmann/json so |
| // that consumers that only need to make authorization decisions (e.g. the mc2 |
| // project or the HFT service core) do not have to pull in the JSON library or |
| // the configuration-loading machinery of the concrete authorizer. |
| class RedfishAuthorizerInterface { |
| public: |
| virtual ~RedfishAuthorizerInterface() = default; |
| |
| // Decides authorization from the resource entity. Does not support any |
| // override. |
| virtual bool IsPeerAuthorized( |
| ecclesia::ResourceEntity resource_entity, ecclesia::Operation operation, |
| const RedfishPrivileges& peer_privileges) const = 0; |
| |
| // Decides authorization from the resource URI. Supports Resource and |
| // Subordinate Overrides but not Property Overrides. |
| virtual bool IsPeerAuthorized( |
| std::string_view uri, ecclesia::Operation operation, |
| const RedfishPrivileges& peer_privileges) const = 0; |
| |
| // Returns the peer's redfish role. Returns an empty string if the peer is not |
| // authorized. |
| virtual std::string GetPeerRedfishRole( |
| const PeerSpiffeIdentity& peer) const = 0; |
| |
| // Returns the sample rate limit for the peer role. |
| virtual uint64_t GetSampleRateLimit(const std::string& peer_role) const = 0; |
| }; |
| |
| } // namespace milotic::authz |
| |
| #endif // THIRD_PARTY_MILOTIC_EXTERNAL_CC_AUTHZ_REDFISH_AUTHORIZER_INTERFACE_H_ |