LCOV - code coverage report
Current view: top level - source/extensions/grpc_credentials/aws_iam - config.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 1 6 16.7 %
Date: 2024-01-05 06:35:25 Functions: 1 4 25.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include "envoy/config/core/v3/grpc_service.pb.h"
       4             : #include "envoy/config/grpc_credential/v3/aws_iam.pb.h"
       5             : #include "envoy/grpc/google_grpc_creds.h"
       6             : #include "envoy/http/header_map.h"
       7             : 
       8             : #include "source/common/http/message_impl.h"
       9             : #include "source/extensions/common/aws/signer.h"
      10             : 
      11             : namespace Envoy {
      12             : namespace Extensions {
      13             : namespace GrpcCredentials {
      14             : namespace AwsIam {
      15             : 
      16             : /**
      17             :  * AWS IAM based gRPC channel credentials factory.
      18             :  */
      19             : class AwsIamGrpcCredentialsFactory : public Grpc::GoogleGrpcCredentialsFactory {
      20             : public:
      21             :   std::shared_ptr<grpc::ChannelCredentials>
      22             :   getChannelCredentials(const envoy::config::core::v3::GrpcService& grpc_service_config,
      23             :                         Api::Api& api) override;
      24             : 
      25           0 :   Envoy::ProtobufTypes::MessagePtr createEmptyConfigProto() {
      26           0 :     return std::make_unique<envoy::config::grpc_credential::v3::AwsIamConfig>();
      27           0 :   }
      28             : 
      29           2 :   std::string name() const override { return "envoy.grpc_credentials.aws_iam"; }
      30             : 
      31             : private:
      32             :   static std::string getRegion(const envoy::config::grpc_credential::v3::AwsIamConfig& config);
      33             : };
      34             : 
      35             : /**
      36             :  * Produce AWS IAM signature metadata for a gRPC call.
      37             :  */
      38             : class AwsIamHeaderAuthenticator : public grpc::MetadataCredentialsPlugin {
      39             : public:
      40           0 :   AwsIamHeaderAuthenticator(Common::Aws::SignerPtr signer) : signer_(std::move(signer)) {}
      41             : 
      42             :   grpc::Status GetMetadata(grpc::string_ref, grpc::string_ref, const grpc::AuthContext&,
      43             :                            std::multimap<grpc::string, grpc::string>* metadata) override;
      44             : 
      45           0 :   bool IsBlocking() const override { return true; }
      46             : 
      47             : private:
      48             :   static Http::RequestMessageImpl buildMessageToSign(absl::string_view service_url,
      49             :                                                      absl::string_view method_name);
      50             : 
      51             :   static void signedHeadersToMetadata(const Http::HeaderMap& headers,
      52             :                                       std::multimap<grpc::string, grpc::string>& metadata);
      53             : 
      54             :   const Common::Aws::SignerPtr signer_;
      55             : };
      56             : 
      57             : } // namespace AwsIam
      58             : } // namespace GrpcCredentials
      59             : } // namespace Extensions
      60             : } // namespace Envoy

Generated by: LCOV version 1.15