LCOV - code coverage report
Current view: top level - source/extensions/common/aws - sigv4_signer_impl.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 1 1 100.0 %
Date: 2024-01-05 06:35:25 Functions: 1 1 100.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <utility>
       4             : 
       5             : #include "source/common/common/logger.h"
       6             : #include "source/common/common/matchers.h"
       7             : #include "source/common/common/utility.h"
       8             : #include "source/common/http/headers.h"
       9             : #include "source/common/singleton/const_singleton.h"
      10             : #include "source/extensions/common/aws/credentials_provider.h"
      11             : #include "source/extensions/common/aws/signer.h"
      12             : #include "source/extensions/common/aws/signer_base_impl.h"
      13             : 
      14             : namespace Envoy {
      15             : namespace Extensions {
      16             : namespace Common {
      17             : namespace Aws {
      18             : 
      19             : using SigV4SignatureHeaders = ConstSingleton<SignatureHeaderValues>;
      20             : 
      21             : class SigV4SignatureConstantValues : public SignatureConstantValues {
      22             : public:
      23             :   const std::string SigV4AuthorizationHeaderFormat{
      24             :       "AWS4-HMAC-SHA256 Credential={}/{}, SignedHeaders={}, Signature={}"};
      25             :   const std::string SigV4CredentialScopeFormat{"{}/{}/{}/aws4_request"};
      26             :   const std::string SigV4SignatureVersion{"AWS4"};
      27             :   const std::string SigV4StringToSignFormat{"AWS4-HMAC-SHA256\n{}\n{}\n{}"};
      28             : };
      29             : 
      30             : using SigV4SignatureConstants = ConstSingleton<SigV4SignatureConstantValues>;
      31             : 
      32             : using AwsSigningHeaderExclusionVector = std::vector<envoy::type::matcher::v3::StringMatcher>;
      33             : 
      34             : /**
      35             :  * Implementation of the Signature V4 signing process.
      36             :  * See https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-signing.html
      37             :  */
      38             : class SigV4SignerImpl : public SignerBaseImpl {
      39             : public:
      40             :   SigV4SignerImpl(absl::string_view service_name, absl::string_view region,
      41             :                   const CredentialsProviderSharedPtr& credentials_provider, TimeSource& time_source,
      42             :                   const AwsSigningHeaderExclusionVector& matcher_config)
      43           6 :       : SignerBaseImpl(service_name, region, credentials_provider, time_source, matcher_config) {}
      44             : 
      45             : private:
      46             :   std::string createCredentialScope(const absl::string_view short_date,
      47             :                                     const absl::string_view override_region) const override;
      48             : 
      49             :   std::string createStringToSign(const absl::string_view canonical_request,
      50             :                                  const absl::string_view long_date,
      51             :                                  const absl::string_view credential_scope) const override;
      52             : 
      53             :   std::string createSignature(ABSL_ATTRIBUTE_UNUSED const absl::string_view access_key_id,
      54             :                               const absl::string_view secret_access_key,
      55             :                               const absl::string_view short_date,
      56             :                               const absl::string_view string_to_sign,
      57             :                               const absl::string_view override_region) const override;
      58             : 
      59             :   std::string createAuthorizationHeader(const absl::string_view access_key_id,
      60             :                                         const absl::string_view credential_scope,
      61             :                                         const std::map<std::string, std::string>& canonical_headers,
      62             :                                         const absl::string_view signature) const override;
      63             : };
      64             : 
      65             : } // namespace Aws
      66             : } // namespace Common
      67             : } // namespace Extensions
      68             : } // namespace Envoy

Generated by: LCOV version 1.15