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
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,24 @@ namespace Aws
public:
using ShouldCreateFunc = std::function<bool(const Aws::String& relativeUri, const Aws::String& absoluteUri, const Aws::String authToken)>;

/**
* Initializes the provider to retrieve credentials from a general http provided endpoint every 5 minutes or before it
* expires.
* @param relativeUri A path appended to the metadata service endpoint. OR
* @param absoluteUri The full URI to resolve to get credentials.
* @param authTokenFilePath A path to a file with optional authorization token passed to the URI via the 'Authorization' HTTP header.
* @param authToken An optional authorization token passed to the URI via the 'Authorization' HTTP header.
* @param refreshRateMs The number of milliseconds after which the credentials will be fetched again.
* @param ShouldCreateFunc
*/
GeneralHTTPCredentialsProvider(const Aws::Client::ClientConfiguration& clientConfig,
const Aws::String& relativeUri,
const Aws::String& absoluteUri,
const Aws::String& authTokenFilePath = "",
const Aws::String& authToken = "",
long refreshRateMs = REFRESH_THRESHOLD,
ShouldCreateFunc shouldCreateFunc = ShouldCreateGeneralHTTPProvider);

/**
* Initializes the provider to retrieve credentials from a general http provided endpoint every 5 minutes or before it
* expires.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,28 @@ bool GeneralHTTPCredentialsProvider::ShouldCreateGeneralHTTPProvider(const Aws::
return false;
}

GeneralHTTPCredentialsProvider::GeneralHTTPCredentialsProvider(const Aws::Client::ClientConfiguration& clientConfig,
const Aws::String& relativeUri,
const Aws::String& absoluteUri,
const Aws::String& authToken,
const Aws::String& authTokenFilePath,
long refreshRateMs,
ShouldCreateFunc shouldCreateFunc) :
m_authTokenFilePath(authTokenFilePath),
m_loadFrequencyMs(refreshRateMs)
{
if (shouldCreateFunc(relativeUri, absoluteUri, authToken))
{
AWS_LOGSTREAM_INFO(GEN_HTTP_LOG_TAG, "Creating GeneralHTTPCredentialsProvider with refresh rate " << refreshRateMs);
if (!relativeUri.empty()) {
m_ecsCredentialsClient = Aws::MakeShared<Aws::Internal::ECSCredentialsClient>(GEN_HTTP_LOG_TAG, clientConfig, relativeUri.c_str(), AWS_ECS_CONTAINER_HOST, authToken.c_str());
}
else if (!absoluteUri.empty()) {
m_ecsCredentialsClient = Aws::MakeShared<Aws::Internal::ECSCredentialsClient>(GEN_HTTP_LOG_TAG, clientConfig, "", absoluteUri.c_str(), authToken.c_str());
}
}
}

GeneralHTTPCredentialsProvider::GeneralHTTPCredentialsProvider(const Aws::String& relativeUri,
const Aws::String& absoluteUri,
const Aws::String& authToken,
Expand Down
Loading