From c73b4cb6436872671273ff2f9a6ab7efa7ce2a4a Mon Sep 17 00:00:00 2001 From: sbiscigl Date: Wed, 28 Aug 2024 10:06:17 -0400 Subject: [PATCH] Fix smithy signer ctors for older gcc --- .../smithy/identity/auth/built-in/SigV4AuthScheme.h | 11 +++++++---- .../identity/auth/built-in/SigV4aAuthScheme.h | 10 ++++++---- .../smithy/identity/signer/built-in/SigV4Signer.h | 11 +++++++---- .../smithy/identity/signer/built-in/SigV4aSigner.h | 13 +++++++------ .../smithy/client/SmithyClientTest.cpp | 9 ++------- 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/SigV4AuthScheme.h b/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/SigV4AuthScheme.h index 2369f841228..60317d062b0 100644 --- a/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/SigV4AuthScheme.h +++ b/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/SigV4AuthScheme.h @@ -26,19 +26,22 @@ namespace smithy { //This allows to override the identity resolver explicit SigV4AuthScheme(std::shared_ptr identityResolver, - const SigV4AuthSchemeParameters& parameters) + const Aws::String& serviceName, + const Aws::String& region) : AuthScheme(SIGV4), m_identityResolver{identityResolver}, - m_signer{Aws::MakeShared("SigV4AuthScheme", parameters)} + m_signer{Aws::MakeShared("SigV4AuthScheme", serviceName, region)} { assert(m_identityResolver); assert(m_signer); } //delegate constructor - explicit SigV4AuthScheme(const SigV4AuthSchemeParameters& parameters) + explicit SigV4AuthScheme(const Aws::String& serviceName, + const Aws::String& region) : SigV4AuthScheme(Aws::MakeShared("SigV4AuthScheme"), - parameters) + serviceName, + region) { } diff --git a/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/SigV4aAuthScheme.h b/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/SigV4aAuthScheme.h index bbb91860830..9a70a5e2a8e 100644 --- a/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/SigV4aAuthScheme.h +++ b/src/aws-cpp-sdk-core/include/smithy/identity/auth/built-in/SigV4aAuthScheme.h @@ -26,17 +26,19 @@ namespace smithy { //This allows to override the identity resolver explicit SigV4aAuthScheme(std::shared_ptr identityResolver, - const SigV4aAuthSchemeParameters& parameters) + const Aws::String& serviceName, + const Aws::String& region) : AuthScheme(SIGV4A), m_identityResolver{identityResolver}, - m_signer{Aws::MakeShared("SigV4aAuthScheme", parameters)} + m_signer{Aws::MakeShared("SigV4aAuthScheme", serviceName, region)} { assert(m_identityResolver); assert(m_signer); } - explicit SigV4aAuthScheme(const SigV4aAuthSchemeParameters& parameters) - : SigV4aAuthScheme(Aws::MakeShared("SigV4aAuthScheme"),parameters ) + explicit SigV4aAuthScheme(const Aws::String& serviceName, + const Aws::String& region) + : SigV4aAuthScheme(Aws::MakeShared("SigV4aAuthScheme"), serviceName, region) { assert(m_identityResolver); diff --git a/src/aws-cpp-sdk-core/include/smithy/identity/signer/built-in/SigV4Signer.h b/src/aws-cpp-sdk-core/include/smithy/identity/signer/built-in/SigV4Signer.h index 3c3f44520f8..46612b873d8 100644 --- a/src/aws-cpp-sdk-core/include/smithy/identity/signer/built-in/SigV4Signer.h +++ b/src/aws-cpp-sdk-core/include/smithy/identity/signer/built-in/SigV4Signer.h @@ -20,8 +20,10 @@ namespace smithy { public: using SigV4AuthSchemeParameters = DefaultAuthSchemeResolverParameters; - explicit AwsSigV4Signer(const SigV4AuthSchemeParameters& parameters) - : m_parameters{parameters},legacySigner{nullptr, parameters.serviceName.c_str(), *parameters.region} + explicit AwsSigV4Signer(const Aws::String& serviceName, const Aws::String& region) + : m_serviceName(serviceName), + m_region(region), + legacySigner(nullptr, serviceName.c_str(), region, Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Always) { } @@ -45,7 +47,7 @@ namespace smithy { bool signPayload = signPayloadIt != properties.end() ? signPayloadIt->second.get() == "true" : false; assert(httpRequest); - bool success = legacySigner.SignRequestWithCreds(*httpRequest, legacyCreds, m_parameters.region->c_str(), m_parameters.serviceName.c_str(), signPayload); + bool success = legacySigner.SignRequestWithCreds(*httpRequest, legacyCreds, m_region.c_str(), m_serviceName.c_str(), signPayload); if (success) { return SigningFutureOutcome(std::move(httpRequest)); @@ -55,7 +57,8 @@ namespace smithy { virtual ~AwsSigV4Signer() {}; protected: - SigV4AuthSchemeParameters m_parameters; + Aws::String m_serviceName; + Aws::String m_region; Aws::Client::AWSAuthV4Signer legacySigner; }; } diff --git a/src/aws-cpp-sdk-core/include/smithy/identity/signer/built-in/SigV4aSigner.h b/src/aws-cpp-sdk-core/include/smithy/identity/signer/built-in/SigV4aSigner.h index 771f68ce202..ce8cde8f0e2 100644 --- a/src/aws-cpp-sdk-core/include/smithy/identity/signer/built-in/SigV4aSigner.h +++ b/src/aws-cpp-sdk-core/include/smithy/identity/signer/built-in/SigV4aSigner.h @@ -32,8 +32,8 @@ namespace smithy { public: using SigV4aAuthSchemeParameters = smithy::DefaultAuthSchemeResolverParameters; - explicit AwsSigV4aSigner(const SigV4aAuthSchemeParameters& parameters) - : m_parameters{parameters} + explicit AwsSigV4aSigner(const Aws::String& serviceName, const Aws::String& region) + : m_serviceName(serviceName), m_region(region) { } @@ -136,8 +136,8 @@ namespace smithy { { awsSigningConfig.SetSigningAlgorithm(static_cast(Aws::Auth::AWSSigningAlgorithm::ASYMMETRIC_SIGV4)); awsSigningConfig.SetSignatureType(m_signatureType); - awsSigningConfig.SetRegion((*m_parameters.region).c_str()); - awsSigningConfig.SetService((m_parameters.serviceName).c_str()); + awsSigningConfig.SetRegion(m_region.c_str()); + awsSigningConfig.SetService(m_region.c_str()); awsSigningConfig.SetSigningTimepoint(GetSigningTimestamp().UnderlyingTimestamp()); awsSigningConfig.SetUseDoubleUriEncode(m_urlEscape); awsSigningConfig.SetShouldNormalizeUriPath(true); @@ -174,7 +174,7 @@ namespace smithy { } else if (m_signatureType == Aws::Crt::Auth::SignatureType::HttpRequestViaQueryParams) { - if (ServiceRequireUnsignedPayload(m_parameters.serviceName)) + if (ServiceRequireUnsignedPayload(m_serviceName)) { awsSigningConfig.SetSignedBodyValue(UNSIGNED_PAYLOAD); } @@ -205,7 +205,8 @@ namespace smithy { return "s3" == serviceName || "s3-object-lambda" == serviceName; } - SigV4aAuthSchemeParameters m_parameters; + Aws::String m_serviceName; + Aws::String m_region; //params that can be exposed later long long m_expirationTimeInSeconds{0}; const bool m_includeSha256HashHeader{true}; diff --git a/tests/aws-cpp-sdk-core-tests/smithy/client/SmithyClientTest.cpp b/tests/aws-cpp-sdk-core-tests/smithy/client/SmithyClientTest.cpp index 3fa693ac676..7bd40e01bb2 100644 --- a/tests/aws-cpp-sdk-core-tests/smithy/client/SmithyClientTest.cpp +++ b/tests/aws-cpp-sdk-core-tests/smithy/client/SmithyClientTest.cpp @@ -130,11 +130,6 @@ TEST_F(SmithyClientTest, testSigV4) { Aws::UnorderedMap authSchemesMap; - smithy::SigV4AuthScheme::SigV4AuthSchemeParameters params; - params.serviceName = "MyService"; - params.region = "us-west2"; - params.operation = "TestOperation"; - Aws::String key{"aws.auth#sigv4"}; //add mock credentials provider for the test to the credentials provider chain @@ -143,7 +138,7 @@ TEST_F(SmithyClientTest, testSigV4) { //create resolver with the credentials provider chain auto credentialsResolver = Aws::MakeShared(ALLOCATION_TAG, credsProviderChain); - SigVariant val{smithy::SigV4AuthScheme( credentialsResolver, params)}; + SigVariant val{smithy::SigV4AuthScheme( credentialsResolver, "MyService", "us-west-2")}; authSchemesMap.emplace(key, val); @@ -196,7 +191,7 @@ TEST_F(SmithyClientTest, testSigV4a) { Aws::String key{"aws.auth#sigv4a"}; auto credentialsResolver = Aws::MakeShared(ALLOCATION_TAG, credsProviderChain); - SigVariant val{smithy::SigV4aAuthScheme(credentialsResolver, params)}; + SigVariant val{smithy::SigV4aAuthScheme(credentialsResolver, "MyService", "us-west-2")}; authSchemesMap.emplace(key, val);