Skip to content

Commit

Permalink
restore file
Browse files Browse the repository at this point in the history
  • Loading branch information
sbera87 committed Nov 25, 2024
1 parent ad14be8 commit 1733616
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions src/aws-cpp-sdk-core/source/internal/AWSHttpResourceClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,33 +602,41 @@ namespace Aws
SSOCredentialsClient::SSOCredentialsClient(const Aws::Client::ClientConfiguration& clientConfiguration, Aws::Http::Scheme scheme, const Aws::String& region)
: AWSHttpResourceClient(clientConfiguration, SSO_RESOURCE_CLIENT_LOG_TAG)
{
(Aws::MakeUnique<Aws::Client::JsonErrorMarshaller>(SSO_RESOURCE_CLIENT_LOG_TAG));
SetErrorMarshaller(Aws::MakeUnique<Aws::Client::JsonErrorMarshaller>(SSO_RESOURCE_CLIENT_LOG_TAG));

m_endpoint = buildEndpoint(scheme, region, "portal.sso.", "federation/credentials");
m_oidcEndpoint = buildEndpoint(scheme, region, "oidc.", "token");
m_endpoint = buildEndpoint(scheme, region, "portal.sso.", "federation/credentials");
m_oidcEndpoint = buildEndpoint(scheme, region, "oidc.", "token");

AWS_LOGSTREAM_INFO(SSO_RESOURCE_CLIENT_LOG_TAG, "Creating SSO ResourceClient with endpoint: " << m_endpoint);
AWS_LOGSTREAM_INFO(SSO_RESOURCE_CLIENT_LOG_TAG, "Creating SSO ResourceClient with endpoint: " << m_endpoint);
}

Aws::String SSOCredentialsClient::buildEndpoint(Aws::Http::Scheme scheme, const Aws::String& region, const Aws::String& domain,
const Aws::String& endpoint) {
Aws::StringStream ss;
if (scheme == Aws::Http::Scheme::HTTP) {
ss << "http://";
} else {
ss << "https://";
}

static const int CN_NORTH_1_HASH = Aws::Utils::HashingUtils::HashString(Aws::Region::CN_NORTH_1);
static const int CN_NORTHWEST_1_HASH = Aws::Utils::HashingUtils::HashString(Aws::Region::CN_NORTHWEST_1);
auto hash = Aws::Utils::HashingUtils::HashString(region.c_str());

AWS_LOGSTREAM_DEBUG(SSO_RESOURCE_CLIENT_LOG_TAG, "Preparing SSO client for region: " << region);
ss << domain << region << ".amazonaws.com/" << endpoint;
if (hash == CN_NORTH_1_HASH || hash == CN_NORTHWEST_1_HASH) {
ss << ".cn";
}
return ss.str();
Aws::String SSOCredentialsClient::buildEndpoint(
Aws::Http::Scheme scheme,
const Aws::String& region,
const Aws::String& domain,
const Aws::String& endpoint)
{
Aws::StringStream ss;
if (scheme == Aws::Http::Scheme::HTTP)
{
ss << "http://";
}
else
{
ss << "https://";
}

static const int CN_NORTH_1_HASH = Aws::Utils::HashingUtils::HashString(Aws::Region::CN_NORTH_1);
static const int CN_NORTHWEST_1_HASH = Aws::Utils::HashingUtils::HashString(Aws::Region::CN_NORTHWEST_1);
auto hash = Aws::Utils::HashingUtils::HashString(region.c_str());

AWS_LOGSTREAM_DEBUG(SSO_RESOURCE_CLIENT_LOG_TAG, "Preparing SSO client for region: " << region);
ss << domain << region << ".amazonaws.com/" << endpoint;
if (hash == CN_NORTH_1_HASH || hash == CN_NORTHWEST_1_HASH)
{
ss << ".cn";
}
return ss.str();
}

SSOCredentialsClient::SSOGetRoleCredentialsResult SSOCredentialsClient::GetSSOCredentials(const SSOGetRoleCredentialsRequest &request)
Expand Down

0 comments on commit 1733616

Please sign in to comment.