Skip to content

Commit 22a229d

Browse files
author
Raúl Gutiérrez Segalés
authored
refactor: move aws signing bits to common/ (envoyproxy#9925)
This was under filter/http/common/aws for historical reasons, so moving it to source/extensions/common/aws where it should live. Signed-off-by: Raul Gutierrez Segales <[email protected]>
1 parent 950c800 commit 22a229d

31 files changed

+70
-110
lines changed

CODEOWNERS

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ extensions/filters/common/original_src @snowp @klarose
5353
/*/extensions/filters/http/cache @toddmgreer @jmarantz
5454
# aws_iam grpc credentials
5555
/*/extensions/grpc_credentials/aws_iam @lavignes @mattklein123
56-
/*/extensions/filters/http/common/aws @lavignes @mattklein123
56+
/*/extensions/common/aws @lavignes @mattklein123
5757
# adaptive concurrency limit extension.
5858
/*/extensions/filters/http/adaptive_concurrency @tonya11en @mattklein123
5959
# http inspector

source/extensions/filters/http/common/aws/credentials_provider.h source/extensions/common/aws/credentials_provider.h

-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace Envoy {
1111
namespace Extensions {
12-
namespace HttpFilters {
1312
namespace Common {
1413
namespace Aws {
1514

@@ -71,6 +70,5 @@ using CredentialsProviderSharedPtr = std::shared_ptr<CredentialsProvider>;
7170

7271
} // namespace Aws
7372
} // namespace Common
74-
} // namespace HttpFilters
7573
} // namespace Extensions
7674
} // namespace Envoy

source/extensions/filters/http/common/aws/credentials_provider_impl.cc source/extensions/common/aws/credentials_provider_impl.cc

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "extensions/filters/http/common/aws/credentials_provider_impl.h"
1+
#include "extensions/common/aws/credentials_provider_impl.h"
22

33
#include "envoy/common/exception.h"
44

@@ -8,7 +8,6 @@
88

99
namespace Envoy {
1010
namespace Extensions {
11-
namespace HttpFilters {
1211
namespace Common {
1312
namespace Aws {
1413

@@ -221,6 +220,5 @@ DefaultCredentialsProviderChain::DefaultCredentialsProviderChain(
221220

222221
} // namespace Aws
223222
} // namespace Common
224-
} // namespace HttpFilters
225223
} // namespace Extensions
226224
} // namespace Envoy

source/extensions/filters/http/common/aws/credentials_provider_impl.h source/extensions/common/aws/credentials_provider_impl.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
#include "common/common/logger.h"
99
#include "common/common/thread.h"
1010

11-
#include "extensions/filters/http/common/aws/credentials_provider.h"
11+
#include "extensions/common/aws/credentials_provider.h"
1212

1313
#include "absl/strings/string_view.h"
1414

1515
namespace Envoy {
1616
namespace Extensions {
17-
namespace HttpFilters {
1817
namespace Common {
1918
namespace Aws {
2019

@@ -165,6 +164,5 @@ class DefaultCredentialsProviderChain : public CredentialsProviderChain,
165164

166165
} // namespace Aws
167166
} // namespace Common
168-
} // namespace HttpFilters
169167
} // namespace Extensions
170168
} // namespace Envoy

source/extensions/filters/http/common/aws/region_provider.h source/extensions/common/aws/region_provider.h

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Envoy {
88
namespace Extensions {
9-
namespace HttpFilters {
109
namespace Common {
1110
namespace Aws {
1211

@@ -28,6 +27,5 @@ using RegionProviderSharedPtr = std::shared_ptr<RegionProvider>;
2827

2928
} // namespace Aws
3029
} // namespace Common
31-
} // namespace HttpFilters
3230
} // namespace Extensions
3331
} // namespace Envoy

source/extensions/filters/http/common/aws/region_provider_impl.cc source/extensions/common/aws/region_provider_impl.cc

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
#include "extensions/filters/http/common/aws/region_provider_impl.h"
1+
#include "extensions/common/aws/region_provider_impl.h"
22

33
namespace Envoy {
44
namespace Extensions {
5-
namespace HttpFilters {
65
namespace Common {
76
namespace Aws {
87

@@ -25,6 +24,5 @@ absl::optional<std::string> EnvironmentRegionProvider::getRegion() {
2524

2625
} // namespace Aws
2726
} // namespace Common
28-
} // namespace HttpFilters
2927
} // namespace Extensions
3028
} // namespace Envoy

source/extensions/filters/http/common/aws/region_provider_impl.h source/extensions/common/aws/region_provider_impl.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
#include "common/common/logger.h"
44

5-
#include "extensions/filters/http/common/aws/region_provider.h"
5+
#include "extensions/common/aws/region_provider.h"
66

77
namespace Envoy {
88
namespace Extensions {
9-
namespace HttpFilters {
109
namespace Common {
1110
namespace Aws {
1211

@@ -33,6 +32,5 @@ class StaticRegionProvider : public RegionProvider {
3332

3433
} // namespace Aws
3534
} // namespace Common
36-
} // namespace HttpFilters
3735
} // namespace Extensions
3836
} // namespace Envoy

source/extensions/filters/http/common/aws/signer.h source/extensions/common/aws/signer.h

-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55

66
namespace Envoy {
77
namespace Extensions {
8-
namespace HttpFilters {
98
namespace Common {
109
namespace Aws {
1110

12-
// TODO(rgs): Move this to source/extensions/common.
1311
class Signer {
1412
public:
1513
virtual ~Signer() = default;
@@ -34,6 +32,5 @@ using SignerPtr = std::unique_ptr<Signer>;
3432

3533
} // namespace Aws
3634
} // namespace Common
37-
} // namespace HttpFilters
3835
} // namespace Extensions
3936
} // namespace Envoy

source/extensions/filters/http/common/aws/signer_impl.cc source/extensions/common/aws/signer_impl.cc

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "extensions/filters/http/common/aws/signer_impl.h"
1+
#include "extensions/common/aws/signer_impl.h"
22

33
#include "envoy/common/exception.h"
44

@@ -8,13 +8,12 @@
88
#include "common/crypto/utility.h"
99
#include "common/http/headers.h"
1010

11-
#include "extensions/filters/http/common/aws/utility.h"
11+
#include "extensions/common/aws/utility.h"
1212

1313
#include "absl/strings/str_join.h"
1414

1515
namespace Envoy {
1616
namespace Extensions {
17-
namespace HttpFilters {
1817
namespace Common {
1918
namespace Aws {
2019

@@ -122,6 +121,5 @@ SignerImpl::createAuthorizationHeader(absl::string_view access_key_id,
122121

123122
} // namespace Aws
124123
} // namespace Common
125-
} // namespace HttpFilters
126124
} // namespace Extensions
127125
} // namespace Envoy

source/extensions/filters/http/common/aws/signer_impl.h source/extensions/common/aws/signer_impl.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
#include "common/common/utility.h"
55
#include "common/singleton/const_singleton.h"
66

7-
#include "extensions/filters/http/common/aws/credentials_provider.h"
8-
#include "extensions/filters/http/common/aws/signer.h"
7+
#include "extensions/common/aws/credentials_provider.h"
8+
#include "extensions/common/aws/signer.h"
99

1010
namespace Envoy {
1111
namespace Extensions {
12-
namespace HttpFilters {
1312
namespace Common {
1413
namespace Aws {
1514

@@ -82,6 +81,5 @@ class SignerImpl : public Signer, public Logger::Loggable<Logger::Id::http> {
8281

8382
} // namespace Aws
8483
} // namespace Common
85-
} // namespace HttpFilters
8684
} // namespace Extensions
8785
} // namespace Envoy

source/extensions/filters/http/common/aws/utility.cc source/extensions/common/aws/utility.cc

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "extensions/filters/http/common/aws/utility.h"
1+
#include "extensions/common/aws/utility.h"
22

33
#include "common/common/fmt.h"
44
#include "common/common/utility.h"
@@ -8,7 +8,6 @@
88

99
namespace Envoy {
1010
namespace Extensions {
11-
namespace HttpFilters {
1211
namespace Common {
1312
namespace Aws {
1413

@@ -141,6 +140,5 @@ absl::optional<std::string> Utility::metadataFetcher(const std::string& host,
141140

142141
} // namespace Aws
143142
} // namespace Common
144-
} // namespace HttpFilters
145143
} // namespace Extensions
146144
} // namespace Envoy

source/extensions/filters/http/common/aws/utility.h source/extensions/common/aws/utility.h

-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Envoy {
66
namespace Extensions {
7-
namespace HttpFilters {
87
namespace Common {
98
namespace Aws {
109

@@ -59,6 +58,5 @@ class Utility {
5958

6059
} // namespace Aws
6160
} // namespace Common
62-
} // namespace HttpFilters
6361
} // namespace Extensions
6462
} // namespace Envoy

source/extensions/filters/http/aws_request_signing/BUILD

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ envoy_cc_library(
1818
hdrs = ["aws_request_signing_filter.h"],
1919
deps = [
2020
"//include/envoy/http:filter_interface",
21+
"//source/extensions/common/aws:credentials_provider_impl_lib",
22+
"//source/extensions/common/aws:signer_impl_lib",
2123
"//source/extensions/filters/http/common:pass_through_filter_lib",
22-
"//source/extensions/filters/http/common/aws:credentials_provider_impl_lib",
23-
"//source/extensions/filters/http/common/aws:signer_impl_lib",
2424
"@envoy_api//envoy/extensions/filters/http/aws_request_signing/v3:pkg_cc_proto",
2525
],
2626
)
@@ -34,10 +34,10 @@ envoy_cc_extension(
3434
deps = [
3535
":aws_request_signing_filter_lib",
3636
"//include/envoy/registry",
37+
"//source/extensions/common/aws:credentials_provider_impl_lib",
38+
"//source/extensions/common/aws:signer_impl_lib",
3739
"//source/extensions/filters/http:well_known_names",
3840
"//source/extensions/filters/http/common:factory_base_lib",
39-
"//source/extensions/filters/http/common/aws:credentials_provider_impl_lib",
40-
"//source/extensions/filters/http/common/aws:signer_impl_lib",
4141
"@envoy_api//envoy/extensions/filters/http/aws_request_signing/v3:pkg_cc_proto",
4242
],
4343
)

source/extensions/filters/http/aws_request_signing/aws_request_signing_filter.cc

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ namespace Extensions {
77
namespace HttpFilters {
88
namespace AwsRequestSigningFilter {
99

10-
FilterConfigImpl::FilterConfigImpl(HttpFilters::Common::Aws::SignerPtr&& signer,
10+
FilterConfigImpl::FilterConfigImpl(Extensions::Common::Aws::SignerPtr&& signer,
1111
const std::string& stats_prefix, Stats::Scope& scope)
1212
: signer_(std::move(signer)), stats_(Filter::generateStats(stats_prefix, scope)) {}
1313

1414
Filter::Filter(const std::shared_ptr<FilterConfig>& config) : config_(config) {}
1515

16-
HttpFilters::Common::Aws::Signer& FilterConfigImpl::signer() { return *signer_; }
16+
Extensions::Common::Aws::Signer& FilterConfigImpl::signer() { return *signer_; }
1717

1818
FilterStats& FilterConfigImpl::stats() { return stats_; }
1919

source/extensions/filters/http/aws_request_signing/aws_request_signing_filter.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "envoy/stats/scope.h"
66
#include "envoy/stats/stats_macros.h"
77

8-
#include "extensions/filters/http/common/aws/signer.h"
8+
#include "extensions/common/aws/signer.h"
99
#include "extensions/filters/http/common/pass_through_filter.h"
1010

1111
namespace Envoy {
@@ -39,7 +39,7 @@ class FilterConfig {
3939
/**
4040
* @return the config's signer.
4141
*/
42-
virtual HttpFilters::Common::Aws::Signer& signer() PURE;
42+
virtual Extensions::Common::Aws::Signer& signer() PURE;
4343

4444
/**
4545
* @return the filter stats.
@@ -54,14 +54,14 @@ using FilterConfigSharedPtr = std::shared_ptr<FilterConfig>;
5454
*/
5555
class FilterConfigImpl : public FilterConfig {
5656
public:
57-
FilterConfigImpl(HttpFilters::Common::Aws::SignerPtr&& signer, const std::string& stats_prefix,
57+
FilterConfigImpl(Extensions::Common::Aws::SignerPtr&& signer, const std::string& stats_prefix,
5858
Stats::Scope& scope);
5959

60-
HttpFilters::Common::Aws::Signer& signer() override;
60+
Extensions::Common::Aws::Signer& signer() override;
6161
FilterStats& stats() override;
6262

6363
private:
64-
HttpFilters::Common::Aws::SignerPtr signer_;
64+
Extensions::Common::Aws::SignerPtr signer_;
6565
FilterStats stats_;
6666
};
6767

source/extensions/filters/http/aws_request_signing/config.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
#include "envoy/extensions/filters/http/aws_request_signing/v3/aws_request_signing.pb.validate.h"
55
#include "envoy/registry/registry.h"
66

7+
#include "extensions/common/aws/credentials_provider_impl.h"
8+
#include "extensions/common/aws/signer_impl.h"
9+
#include "extensions/common/aws/utility.h"
710
#include "extensions/filters/http/aws_request_signing/aws_request_signing_filter.h"
8-
#include "extensions/filters/http/common/aws/credentials_provider_impl.h"
9-
#include "extensions/filters/http/common/aws/signer_impl.h"
10-
#include "extensions/filters/http/common/aws/utility.h"
1111

1212
namespace Envoy {
1313
namespace Extensions {
@@ -19,9 +19,9 @@ Http::FilterFactoryCb AwsRequestSigningFilterFactory::createFilterFactoryFromPro
1919
const std::string& stats_prefix, Server::Configuration::FactoryContext& context) {
2020

2121
auto credentials_provider =
22-
std::make_shared<HttpFilters::Common::Aws::DefaultCredentialsProviderChain>(
23-
context.api(), HttpFilters::Common::Aws::Utility::metadataFetcher);
24-
auto signer = std::make_unique<HttpFilters::Common::Aws::SignerImpl>(
22+
std::make_shared<Extensions::Common::Aws::DefaultCredentialsProviderChain>(
23+
context.api(), Extensions::Common::Aws::Utility::metadataFetcher);
24+
auto signer = std::make_unique<Extensions::Common::Aws::SignerImpl>(
2525
config.service_name(), config.region(), credentials_provider,
2626
context.dispatcher().timeSource());
2727

source/extensions/grpc_credentials/aws_iam/BUILD

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ envoy_cc_extension(
2525
"//source/common/grpc:google_grpc_creds_lib",
2626
"//source/common/http:message_lib",
2727
"//source/common/http:utility_lib",
28-
"//source/extensions/filters/http/common/aws:credentials_provider_impl_lib",
29-
"//source/extensions/filters/http/common/aws:region_provider_impl_lib",
30-
"//source/extensions/filters/http/common/aws:signer_impl_lib",
31-
"//source/extensions/filters/http/common/aws:utility_lib",
28+
"//source/extensions/common/aws:credentials_provider_impl_lib",
29+
"//source/extensions/common/aws:region_provider_impl_lib",
30+
"//source/extensions/common/aws:signer_impl_lib",
31+
"//source/extensions/common/aws:utility_lib",
3232
"//source/extensions/grpc_credentials:well_known_names",
3333
"@envoy_api//envoy/config/core/v3:pkg_cc_proto",
3434
"@envoy_api//envoy/config/grpc_credential/v3:pkg_cc_proto",

source/extensions/grpc_credentials/aws_iam/config.cc

+10-12
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
#include "common/http/utility.h"
1313
#include "common/protobuf/message_validator_impl.h"
1414

15-
#include "extensions/filters/http/common/aws/credentials_provider_impl.h"
16-
#include "extensions/filters/http/common/aws/region_provider_impl.h"
17-
#include "extensions/filters/http/common/aws/signer_impl.h"
18-
#include "extensions/filters/http/common/aws/utility.h"
15+
#include "extensions/common/aws/credentials_provider_impl.h"
16+
#include "extensions/common/aws/region_provider_impl.h"
17+
#include "extensions/common/aws/signer_impl.h"
18+
#include "extensions/common/aws/utility.h"
1919

2020
namespace Envoy {
2121
namespace Extensions {
@@ -45,10 +45,9 @@ std::shared_ptr<grpc::ChannelCredentials> AwsIamGrpcCredentialsFactory::getChann
4545
const auto& config = Envoy::MessageUtil::downcastAndValidate<
4646
const envoy::config::grpc_credential::v3::AwsIamConfig&>(
4747
*config_message, ProtobufMessage::getNullValidationVisitor());
48-
auto credentials_provider =
49-
std::make_shared<HttpFilters::Common::Aws::DefaultCredentialsProviderChain>(
50-
api, HttpFilters::Common::Aws::Utility::metadataFetcher);
51-
auto signer = std::make_unique<HttpFilters::Common::Aws::SignerImpl>(
48+
auto credentials_provider = std::make_shared<Common::Aws::DefaultCredentialsProviderChain>(
49+
api, Common::Aws::Utility::metadataFetcher);
50+
auto signer = std::make_unique<Common::Aws::SignerImpl>(
5251
config.service_name(), getRegion(config), credentials_provider, api.timeSource());
5352
std::shared_ptr<grpc::CallCredentials> new_call_creds = grpc::MetadataCredentialsFromPlugin(
5453
std::make_unique<AwsIamHeaderAuthenticator>(std::move(signer)));
@@ -75,12 +74,11 @@ std::shared_ptr<grpc::ChannelCredentials> AwsIamGrpcCredentialsFactory::getChann
7574

7675
std::string AwsIamGrpcCredentialsFactory::getRegion(
7776
const envoy::config::grpc_credential::v3::AwsIamConfig& config) {
78-
std::unique_ptr<HttpFilters::Common::Aws::RegionProvider> region_provider;
77+
std::unique_ptr<Common::Aws::RegionProvider> region_provider;
7978
if (!config.region().empty()) {
80-
region_provider =
81-
std::make_unique<HttpFilters::Common::Aws::StaticRegionProvider>(config.region());
79+
region_provider = std::make_unique<Common::Aws::StaticRegionProvider>(config.region());
8280
} else {
83-
region_provider = std::make_unique<HttpFilters::Common::Aws::EnvironmentRegionProvider>();
81+
region_provider = std::make_unique<Common::Aws::EnvironmentRegionProvider>();
8482
}
8583

8684
if (!region_provider->getRegion().has_value()) {

0 commit comments

Comments
 (0)