Skip to content

Conversation

kai-ion
Copy link
Contributor

@kai-ion kai-ion commented Aug 13, 2025

Issue #, if available:

Description of changes:

Check all that applies:

  • Did a review by yourself.
  • Added proper tests to cover this PR. (If tests are not applicable, explain.)
  • Checked if this PR is a breaking (APIs have been changed) change.
  • Checked if this PR will not introduce cross-platform inconsistent behavior.
  • Checked if this PR would require a ReadMe/Wiki update.

Check which platforms you have built SDK on to verify the correctness of this PR.

  • Linux
  • Windows
  • Android
  • MacOS
  • IOS
  • Other Platforms

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@kai-ion kai-ion force-pushed the cailinn branch 2 times, most recently from 4614d25 to 29614f4 Compare August 22, 2025 17:56
case Aws::Client::UserAgentFeature::CREDENTIALS_ENV_VARS:
featureStr = "g";
break;
case Aws::Client::UserAgentFeature::CREDENTIALS_SIGV4_SIGNER:
Copy link
Contributor

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/"
Copy link
Contributor

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" });
}

@sbiscigl sbiscigl force-pushed the cailinn branch 3 times, most recently from 43dee9c to 595866d Compare August 28, 2025 18:50
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants