Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,16 @@ const char* DynamoDBClient::GetAllocationTag() { return ALLOCATION_TAG; }

DynamoDBClient::DynamoDBClient(const DynamoDB::DynamoDBClientConfiguration& clientConfiguration,
std::shared_ptr<DynamoDBEndpointProviderBase> endpointProvider)
: AwsSmithyClientT(clientConfiguration, GetServiceName(), "DynamoDB", Aws::Http::CreateHttpClient(clientConfiguration),
Aws::MakeShared<DynamoDBErrorMarshaller>(ALLOCATION_TAG),
endpointProvider ? endpointProvider : Aws::MakeShared<DynamoDBEndpointProvider>(ALLOCATION_TAG),
Aws::MakeShared<smithy::GenericAuthSchemeResolver<>>(
ALLOCATION_TAG, Aws::Vector<smithy::AuthSchemeOption>({smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption})),
{
{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId,
smithy::SigV4AuthScheme{GetServiceName(), clientConfiguration.region}},
}) {}
: AwsSmithyClientT(
clientConfiguration, GetServiceName(), "DynamoDB", Aws::Http::CreateHttpClient(clientConfiguration),
Aws::MakeShared<DynamoDBErrorMarshaller>(ALLOCATION_TAG),
endpointProvider ? endpointProvider : Aws::MakeShared<DynamoDBEndpointProvider>(ALLOCATION_TAG),
Aws::MakeShared<smithy::GenericAuthSchemeResolver<>>(
ALLOCATION_TAG, Aws::Vector<smithy::AuthSchemeOption>({smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption})),
{
{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId,
smithy::SigV4AuthScheme{GetServiceName(), clientConfiguration.region, clientConfiguration.credentialProviderConfig}},
}) {}

DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials, std::shared_ptr<DynamoDBEndpointProviderBase> endpointProvider,
const DynamoDB::DynamoDBClientConfiguration& clientConfiguration)
Expand Down Expand Up @@ -148,7 +149,8 @@ DynamoDBClient::DynamoDBClient(const Client::ClientConfiguration& clientConfigur
ALLOCATION_TAG, Aws::Vector<smithy::AuthSchemeOption>({smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption})),
{
{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId,
smithy::SigV4AuthScheme{Aws::MakeShared<smithy::DefaultAwsCredentialIdentityResolver>(ALLOCATION_TAG),
smithy::SigV4AuthScheme{Aws::MakeShared<smithy::DefaultAwsCredentialIdentityResolver>(
ALLOCATION_TAG, clientConfiguration.credentialProviderConfig),
GetServiceName(), clientConfiguration.region}},
}) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ class BearerTokenAuthScheme : public AuthScheme<AwsBearerTokenIdentityBase>
assert(m_signer);
}

explicit BearerTokenAuthScheme(const Aws::String &serviceName, const Aws::String &region,
const Aws::Client::ClientConfiguration::CredentialProviderConfiguration& config)
: BearerTokenAuthScheme(Aws::MakeShared<DefaultAwsBearerTokenIdentityResolver>("BearerTokenAuthScheme"), serviceName, region) {
AWS_UNREFERENCED_PARAM(config);
assert(m_identityResolver);
assert(m_signer);
}

explicit BearerTokenAuthScheme(const Aws::String &serviceName,
const Aws::String &region)
: BearerTokenAuthScheme(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ namespace smithy {
assert(m_identityResolver);
}

explicit NoAuthScheme(const Aws::String& serviceName, const Aws::String& region,
const Aws::Client::ClientConfiguration::CredentialProviderConfiguration& config)
: NoAuthScheme(nullptr, serviceName, region)
{
AWS_UNREFERENCED_PARAM(config);
assert(m_signer);
assert(m_identityResolver);
}

//legacy constructors
explicit NoAuthScheme(std::shared_ptr<AwsCredentialIdentityResolverT> identityResolver, const Aws::String& serviceName, const Aws::String& region, Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy policy, bool urlEscape)
: AuthScheme(NOAUTH),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ namespace smithy {
{
}

explicit SigV4AuthScheme(const Aws::String& serviceName, const Aws::String& region,
const Aws::Client::ClientConfiguration::CredentialProviderConfiguration& config)
: SigV4AuthScheme(
Aws::MakeShared<DefaultAwsCredentialIdentityResolver>("SigV4AuthScheme", config),
serviceName, region) {}

//For legacy constructors, signing requires additional input parameters
explicit SigV4AuthScheme(const Aws::String& serviceName,
const Aws::String& region,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ namespace smithy {
assert(m_signer);
}

explicit SigV4aAuthScheme(const Aws::String& serviceName, const Aws::String& region,
const Aws::Client::ClientConfiguration::CredentialProviderConfiguration& config)
: SigV4aAuthScheme(
Aws::MakeShared<DefaultAwsCredentialIdentityResolver>("SigV4aAuthScheme", config),
serviceName, region) {
assert(m_identityResolver);
assert(m_signer);
}

explicit SigV4aAuthScheme(const Aws::String& serviceName,
const Aws::String& region)
: SigV4aAuthScheme(Aws::MakeShared<DefaultAwsCredentialIdentityResolver>("SigV4aAuthScheme"), serviceName, region)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,53 @@
*/
#pragma once

#include <smithy/identity/resolver/AwsCredentialIdentityResolver.h>

#include <aws/core/auth/AWSCredentials.h>
#include <aws/core/auth/AWSCredentialsProviderChain.h>
#include <smithy/identity/resolver/AwsCredentialIdentityResolver.h>

namespace smithy {
constexpr char ALLOC_ID[] = "DefaultAwsCredentialIdentityResolver";
/**
* A smithy SigV4 AWS Credentials resolver wrapper on top of legacy SDK Credentials provider
* TODO: refactor into own signer using smithy design
*/
class DefaultAwsCredentialIdentityResolver : public AwsCredentialIdentityResolver {
protected:

mutable std::shared_ptr<Aws::Auth::AWSCredentialsProviderChain> legacyChain_sp;

public:
using SigV4AuthSchemeParameters = DefaultAuthSchemeResolverParameters;

DefaultAwsCredentialIdentityResolver(): legacyChain_sp{Aws::MakeShared<Aws::Auth::DefaultAWSCredentialsProviderChain>(ALLOC_ID)}{

};

DefaultAwsCredentialIdentityResolver(const Aws::Auth::DefaultAWSCredentialsProviderChain& credChain): legacyChain_sp{Aws::MakeShared<Aws::Auth::DefaultAWSCredentialsProviderChain>(ALLOC_ID, credChain)}{

};

DefaultAwsCredentialIdentityResolver(const DefaultAwsCredentialIdentityResolver& other) = delete;
DefaultAwsCredentialIdentityResolver(DefaultAwsCredentialIdentityResolver&& other) noexcept = default;
DefaultAwsCredentialIdentityResolver& operator=(const DefaultAwsCredentialIdentityResolver& other) = delete;
DefaultAwsCredentialIdentityResolver& operator=(DefaultAwsCredentialIdentityResolver&& other) noexcept = default;
virtual ~DefaultAwsCredentialIdentityResolver() = default;

DefaultAwsCredentialIdentityResolver(std::shared_ptr<Aws::Auth::AWSCredentialsProviderChain> providerChain): legacyChain_sp{providerChain}
{
assert(legacyChain_sp);
};

ResolveIdentityFutureOutcome getIdentity(const IdentityProperties& identityProperties, const AdditionalParameters& additionalParameters) override
{
AWS_UNREFERENCED_PARAM(identityProperties);
AWS_UNREFERENCED_PARAM(additionalParameters);

auto legacyCreds = legacyChain_sp->GetAWSCredentials();

auto smithyCreds = Aws::MakeUnique<AwsCredentialIdentity>("DefaultAwsCredentialIdentityResolver",
legacyCreds.GetAWSAccessKeyId(),
legacyCreds.GetAWSSecretKey(),
legacyCreds.GetSessionToken().empty()? Aws::Crt::Optional<Aws::String>() : legacyCreds.GetSessionToken(),
legacyCreds.GetExpiration(),
legacyCreds.GetAccountId().empty()? Aws::Crt::Optional<Aws::String>() : legacyCreds.GetAccountId());

return ResolveIdentityFutureOutcome(std::move(smithyCreds));
}
};
}
constexpr char ALLOC_ID[] = "DefaultAwsCredentialIdentityResolver";
/**
* A smithy SigV4 AWS Credentials resolver wrapper on top of legacy SDK Credentials provider
* TODO: refactor into own signer using smithy design
*/
class DefaultAwsCredentialIdentityResolver : public AwsCredentialIdentityResolver {
protected:
mutable std::shared_ptr<Aws::Auth::AWSCredentialsProviderChain> legacyChain_sp;

public:
using SigV4AuthSchemeParameters = DefaultAuthSchemeResolverParameters;

DefaultAwsCredentialIdentityResolver() : legacyChain_sp{Aws::MakeShared<Aws::Auth::DefaultAWSCredentialsProviderChain>(ALLOC_ID)} {};
DefaultAwsCredentialIdentityResolver(const Aws::Client::ClientConfiguration::CredentialProviderConfiguration& config)
: legacyChain_sp{Aws::MakeShared<Aws::Auth::DefaultAWSCredentialsProviderChain>(ALLOC_ID, config)} {};
DefaultAwsCredentialIdentityResolver(const Aws::Auth::DefaultAWSCredentialsProviderChain& credChain)
: legacyChain_sp{Aws::MakeShared<Aws::Auth::DefaultAWSCredentialsProviderChain>(ALLOC_ID, credChain)} {};

DefaultAwsCredentialIdentityResolver(const DefaultAwsCredentialIdentityResolver& other) = delete;
DefaultAwsCredentialIdentityResolver(DefaultAwsCredentialIdentityResolver&& other) noexcept = default;
DefaultAwsCredentialIdentityResolver& operator=(const DefaultAwsCredentialIdentityResolver& other) = delete;
DefaultAwsCredentialIdentityResolver& operator=(DefaultAwsCredentialIdentityResolver&& other) noexcept = default;
virtual ~DefaultAwsCredentialIdentityResolver() = default;

DefaultAwsCredentialIdentityResolver(std::shared_ptr<Aws::Auth::AWSCredentialsProviderChain> providerChain)
: legacyChain_sp{providerChain} {
assert(legacyChain_sp);
};

ResolveIdentityFutureOutcome getIdentity(const IdentityProperties& identityProperties,
const AdditionalParameters& additionalParameters) override {
AWS_UNREFERENCED_PARAM(identityProperties);
AWS_UNREFERENCED_PARAM(additionalParameters);

auto legacyCreds = legacyChain_sp->GetAWSCredentials();

auto smithyCreds = Aws::MakeUnique<AwsCredentialIdentity>(
"DefaultAwsCredentialIdentityResolver", legacyCreds.GetAWSAccessKeyId(), legacyCreds.GetAWSSecretKey(),
legacyCreds.GetSessionToken().empty() ? Aws::Crt::Optional<Aws::String>() : legacyCreds.GetSessionToken(),
legacyCreds.GetExpiration(), legacyCreds.GetAccountId().empty() ? Aws::Crt::Optional<Aws::String>() : legacyCreds.GetAccountId());

return ResolveIdentityFutureOutcome(std::move(smithyCreds));
}
};
} // namespace smithy
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ ${className}::${className}(const ${clientConfiguration}& clientConfiguration,
{
#if($serviceModel.metadata.serviceId == "S3")
[&]() -> Aws::UnorderedMap<Aws::String, ${rootNamespace}::Crt::Variant<${AuthSchemeVariants}> > {
auto credsResolver = Aws::MakeShared<smithy::DefaultAwsCredentialIdentityResolver>(ALLOCATION_TAG);
auto credsResolver = Aws::MakeShared<smithy::DefaultAwsCredentialIdentityResolver>(ALLOCATION_TAG, clientConfiguration.credentialProviderConfig);
return {
#foreach($entry in $AuthSchemeMapEntries)
#if($AuthSchemes && $AuthSchemes[$foreach.index] == $s3_express_auth)
Expand All @@ -82,7 +82,7 @@ ${className}::${className}(const ${clientConfiguration}& clientConfiguration,
}()
#else
#foreach($entry in $AuthSchemeMapEntries)
{${entry}{GetServiceName(), clientConfiguration.region}},
{${entry}{GetServiceName(), clientConfiguration.region, clientConfiguration.credentialProviderConfig}},
#end
#end
})
Expand Down Expand Up @@ -188,7 +188,7 @@ ${className}::${className}(const Client::ClientConfiguration& clientConfiguratio
Aws::MakeShared<${AuthSchemeResolver}>(ALLOCATION_TAG),
{
[&]() -> Aws::UnorderedMap<Aws::String, ${rootNamespace}::Crt::Variant<${AuthSchemeVariants}> > {
auto credsResolver = Aws::MakeShared<smithy::DefaultAwsCredentialIdentityResolver>(ALLOCATION_TAG);
auto credsResolver = Aws::MakeShared<smithy::DefaultAwsCredentialIdentityResolver>(ALLOCATION_TAG, clientConfiguration.credentialProviderConfig);
return {
#foreach($entry in $AuthSchemeMapEntries)
#if($AuthSchemes && $AuthSchemes[$foreach.index] == $s3_express_auth)
Expand Down Expand Up @@ -271,7 +271,7 @@ ${className}::${className}(const ${className} &rhs) :
Aws::Client::ClientWithAsyncTemplateMethods<S3Client>(), AwsSmithyClientT(rhs) {
m_authSchemes =
[&]() -> Aws::UnorderedMap<Aws::String, ${rootNamespace}::Crt::Variant<${AuthSchemeVariants}> > {
auto credsResolver = Aws::MakeShared<smithy::DefaultAwsCredentialIdentityResolver>(ALLOCATION_TAG);
auto credsResolver = Aws::MakeShared<smithy::DefaultAwsCredentialIdentityResolver>(ALLOCATION_TAG, clientConfiguration.credentialProviderConfig);
return {
#foreach($entry in $AuthSchemeMapEntries)
#if($AuthSchemes && $AuthSchemes[$foreach.index] == $s3_express_auth)
Expand Down Expand Up @@ -304,7 +304,7 @@ ${className}::${className}(const Client::ClientConfiguration& clientConfiguratio
#if($entry.contains("smithy::BearerTokenAuthScheme"))
{${entry}{Aws::MakeShared<smithy::AwsBearerTokenIdentityResolver>(ALLOCATION_TAG), GetServiceName(), clientConfiguration.region}},
#else
{$entry{Aws::MakeShared<smithy::DefaultAwsCredentialIdentityResolver>(ALLOCATION_TAG), GetServiceName(), clientConfiguration.region}},
{$entry{Aws::MakeShared<smithy::DefaultAwsCredentialIdentityResolver>(ALLOCATION_TAG, clientConfiguration.credentialProviderConfig), GetServiceName(), clientConfiguration.region}},
#end
#end
})
Expand Down
Loading