-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[C++] SDKs to track feature Ids for Credentials (ENV) #3516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
src/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentialsProvider.h
Outdated
Show resolved
Hide resolved
src/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentialsProviderChain.h
Outdated
Show resolved
Hide resolved
src/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentialsProviderChain.h
Outdated
Show resolved
Hide resolved
tests/aws-cpp-sdk-core-tests/aws/auth/CredentialTrackingTest.cpp
Outdated
Show resolved
Hide resolved
src/aws-cpp-sdk-core/source/auth/AWSCredentialsProviderChain.cpp
Outdated
Show resolved
Hide resolved
4614d25
to
29614f4
Compare
src/aws-cpp-sdk-core/include/aws/core/auth/AWSCredentialsProvider.h
Outdated
Show resolved
Hide resolved
case Aws::Client::UserAgentFeature::CREDENTIALS_ENV_VARS: | ||
featureStr = "g"; | ||
break; | ||
case Aws::Client::UserAgentFeature::CREDENTIALS_SIGV4_SIGNER: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no this isnt what we want to be doing, taking a look at the existing user agent
user-agent:
aws-sdk-cpp/1.11.635
ua/2.1
api/S3
os/Darwin#24.6.0
lang/c++#C++11
md/aws-crt#0.33.4
md/arch#arm64
md/Clang#17.0.0
m/D,Z,b,P
what we want to add md/override_get_credentials
to see if the actual method was overrode
|
||
if (mPos != Aws::String::npos) { | ||
// "m/" section already exists, find where to insert our metrics | ||
size_t metricsStart = mPos + 3; // Position after "m/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is kind of sketchy lets find the business metrics value in the user agent and re-assemble it.
auto userAgentParsed = Utils::StringUtils::Split(userAgent, ' ');
auto metricsSegment = std::find_if(userAgentParsed.begin(), userAgentParsed.end(), [](const Aws::String & value) { return value.find("m/") != Aws::String::npos; });
if (metricsSegment != userAgentParsed.end()) {
*metricsSegment = Aws::String{*metricsSegment + ",whatever_you_want"};
request.SetHeaderValue(USER_AGENT,
std::accumulate(std::next(userAgentParsed.begin()), userAgentParsed.end(), userAgentParsed.front(),
[](const std::string& a, const std::string& b) {
return a + "," + b;
}));
} else {
request.SetHeaderValue(USER_AGENT, Aws::String{request.GetHeaderValue(USER_AGENT) + ",whatever_you_want" });
}
43dee9c
to
595866d
Compare
Implement User-Agent 2.1 business metrics for credential provider tracking across the AWS SDK for C++. Key Changes: - Add CredentialsResolutionContext class to track credential features during resolution - Add new UserAgentFeature enums for credential providers (ENV_VARS='g', SSO='s', STS_ASSUME_ROLE='i') - Update AWSAuthV4Signer to collect and inject credential tracking into User-Agent headers - Embed CredentialsResolutionContext directly in AWSCredentials for seamless tracking - Add comprehensive unit tests for credential tracking functionality Supported Credential Providers: - Environment variables (AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY) The implementation returns context as part of credentials rather than requiring API changes. Credential features are automatically tracked during resolution and injected into User-Agent strings during request signing. Resolves credential provider tracking requirements for User-Agent 2.1 business metrics specification.
Issue #, if available:
Description of changes:
Check all that applies:
Check which platforms you have built SDK on to verify the correctness of this PR.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.