Line data Source code
1 : #pragma once 2 : 3 : #include "envoy/common/pure.h" 4 : #include "envoy/http/message.h" 5 : 6 : namespace Envoy { 7 : namespace Extensions { 8 : namespace Common { 9 : namespace Aws { 10 : 11 : class Signer { 12 : public: 13 6 : virtual ~Signer() = default; 14 : 15 : /** 16 : * Sign an AWS request. 17 : * @param message an AWS API request message. 18 : * @param sign_body include the message body in the signature. The body must be fully buffered. 19 : * @param override_region override the default region that has to be used to sign the request 20 : * @throws EnvoyException if the request cannot be signed. 21 : */ 22 : virtual void sign(Http::RequestMessage& message, bool sign_body, 23 : const absl::string_view override_region = "") PURE; 24 : 25 : /** 26 : * Sign an AWS request without a payload (empty string used as content hash). 27 : * @param headers AWS API request headers. 28 : * @param override_region override the default region that has to be used to sign the request 29 : * @throws EnvoyException if the request cannot be signed. 30 : */ 31 : virtual void signEmptyPayload(Http::RequestHeaderMap& headers, 32 : const absl::string_view override_region = "") PURE; 33 : 34 : /** 35 : * Sign an AWS request using the literal string UNSIGNED-PAYLOAD in the canonical request. 36 : * @param headers AWS API request headers. 37 : * @param override_region override the default region that has to be used to sign the request 38 : * @throws EnvoyException if the request cannot be signed. 39 : */ 40 : virtual void signUnsignedPayload(Http::RequestHeaderMap& headers, 41 : const absl::string_view override_region = "") PURE; 42 : 43 : /** 44 : * Sign an AWS request. 45 : * @param headers AWS API request headers. 46 : * @param content_hash The Hex encoded SHA-256 of the body of the AWS API request. 47 : * @param override_region override the default region that has to be used to sign the request 48 : * @throws EnvoyException if the request cannot be signed. 49 : */ 50 : virtual void sign(Http::RequestHeaderMap& headers, const std::string& content_hash, 51 : const absl::string_view override_region = "") PURE; 52 : }; 53 : 54 : using SignerPtr = std::unique_ptr<Signer>; 55 : 56 : } // namespace Aws 57 : } // namespace Common 58 : } // namespace Extensions 59 : } // namespace Envoy