Repository navigation
fix(libstore/aws-creds): use S3 URL region as STS WebIdentity fallback - #15594
Merged
Merged
Conversation
lovesegfault
force-pushed
the
beme/aws-fix-sso
branch
from
March 29, 2026 01:22
d1c2059 to
979fa7d
Compare
When authenticating to an S3 binary cache via STS WebIdentity (EKS IRSA, GitHub Actions OIDC), the aws-c-auth provider needs a region to select an STS endpoint. It looks in AWS_REGION, AWS_DEFAULT_REGION, then the profile config. In IRSA setups that export AWS_WEB_IDENTITY_TOKEN_FILE and AWS_ROLE_ARN but no region — and additionally set AWS_CONFIG_FILE=/dev/null to suppress SSO/profile interference — all three sources are absent. The provider returns nullptr, the credential chain silently skips it, and the user sees a misleading 'IMDS provider' failure. Thread the ?region= parameter from the parsed S3 URL through to the STS WebIdentity provider as a last-resort fallback. aws-c-auth gives options.region precedence over env vars, so we only set it when neither AWS_REGION nor AWS_DEFAULT_REGION is present, preserving existing behaviour for users who do set a region. The credential-provider cache key changes from profile to (profile, region) since the region is baked into the provider at construction time.
lovesegfault
force-pushed
the
beme/aws-fix-sso
branch
from
March 29, 2026 01:31
979fa7d to
05ff8f2
Compare
edolstra
approved these changes
Mar 30, 2026
Comment on lines
+341
to
+342
| boost:: | ||
| concurrent_flat_map<std::pair<std::string, std::string>, std::shared_ptr<Aws::Crt::Auth::ICredentialsProvider>> |
Member
There was a problem hiding this comment.
This line break seems odd?
Suggested change
| boost:: | |
| concurrent_flat_map<std::pair<std::string, std::string>, std::shared_ptr<Aws::Crt::Auth::ICredentialsProvider>> | |
| boost::concurrent_flat_map<std::pair<std::string, std::string>, std::shared_ptr<Aws::Crt::Auth::ICredentialsProvider>> |
Member
Author
There was a problem hiding this comment.
clang-format is adamant that this is right, can't get it to budge
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
When authenticating to an S3 binary cache via STS WebIdentity (EKS IRSA, GitHub Actions OIDC), aws-c-auth's
aws_credentials_provider_new_sts_web_identityneeds a region to select an STS endpoint. It resolves this from, in order:options.region(not currently set by Nix)AWS_REGION/AWS_DEFAULT_REGIONenv varsIn IRSA setups that export
AWS_WEB_IDENTITY_TOKEN_FILEandAWS_ROLE_ARNbut no region — and additionally setAWS_CONFIG_FILE=/dev/nullto suppress SSO/profile interference — all three sources are absent. The provider returnsnullptr, the credential chain silently skips it, and the user sees a misleading error:Meanwhile the S3 URL itself already carries the region as
?region=us-east-1, which Nix parses intoParsedS3URL::regionbut doesn't pass to the credential chain.Changes
url.regionthroughgetCredentials→getCredentialsRaw→createProviderForProfile→createSTSWebIdentityProvider.options.regionwhen neitherAWS_REGIONnorAWS_DEFAULT_REGIONis present. aws-c-auth givesoptions.regionprecedence over env vars, so unconditional setting would mask a user-supplied region.profileto(profile, region)since the region is baked into the provider at construction time.Context
Ran into this on an EKS dev environment where a wrapper script forces IRSA by exporting the token file and role ARN while nulling out the config file. Any regional STS endpoint can assume a role in any region, so using the bucket's region as the STS endpoint is a reasonable fallback.
Checklist
aws-creds.cc