-
Notifications
You must be signed in to change notification settings - Fork 30
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
assumeRole chain support #224
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #224 +/- ##
==========================================
+ Coverage 79.57% 79.62% +0.05%
==========================================
Files 33 33
Lines 5798 5832 +34
==========================================
+ Hits 4614 4644 +30
- Misses 1184 1188 +4 ☔ View full report in Codecov by Sentry. |
allocator, | ||
3, | ||
aws_hash_byte_cursor_ptr, | ||
(aws_hash_callback_eq_fn *)aws_byte_cursor_eq, |
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.
any function type casting is ub. it will probably work in most cases, but its still better to wrap
@@ -428,11 +455,35 @@ struct aws_credentials_provider *aws_credentials_provider_new_profile( | |||
goto on_finished; | |||
} | |||
const struct aws_profile_property *role_arn_property = aws_profile_get_property(profile, s_role_arn_name); | |||
bool profile_contains_access_key = aws_profile_get_property(profile, s_access_key_id_profile_var); | |||
bool profile_contains_secret_access_key = aws_profile_get_property(profile, s_secret_access_key_profile_var); | |||
bool profile_contains_credentials = profile_contains_access_key || profile_contains_secret_access_key; |
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.
should this be end? cred should not be valid if it only contains one of the 2
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.
It's an Or
condition so that we don't treat the profile as an STS profile, even if partial creds are present at https://github.com/awslabs/aws-c-auth/pull/224/files#diff-f7cca12a8538a30712ad4b18e39bb61a240457b820982e916f6f27e76628c64fR477. Later, we fail the creation as invalid if either of them is missing at https://github.com/awslabs/aws-c-auth/pull/224/files#diff-f7cca12a8538a30712ad4b18e39bb61a240457b820982e916f6f27e76628c64fR481. This handles cases where the config file is as follows:
[profile userA]
role_arn = arn
source_profile = userB
[profile userB]
role_arn = arn
aws_access_key_id = accessJey
source_profile = userC
[profile userC]
aws_access_key_id = acess_key
secret_access_key_id = secret
We should fail the request at profileB due to partial credentials instead of using creds from profileC. I copied this behavior from the AWS CLI.
Co-authored-by: Michael Graeb <[email protected]>
Description of changes:
Adds support for STS assumeRole chaining.
Rules:
source_profile
.Examples:
ProfileA
contains static credsProfileA
contains static creds as well as source profile set toProfileA
ProfileA
to call the sts assumeRole and returns the credentials from the sts assumeRole call.ProfileA
containssource_profile
set toProfileB
.ProfileB
contains static creds.ProfileB
to call the sts assumeRole and return the credentials from the sts assumeRole call.ProfileA
containssource_profile
set toProfileB
.ProfileB
containssource_profile
set toProfileC
.ProfileC
contains static creds.ProfileC
to call the sts assumeRole withrole_arn
fromprofileB
.role_arn
fromprofileA
.ProfileA
containssource_profile
set toProfileB
.ProfileB
containssource_profile
set toProfileC
and static creds.ProfileC
contains static creds.ProfileB
to call the sts assumeRole withrole_arn
fromprofileA
.ProfileA
containssource_profile
set toProfileB
.ProfileB
containssource_profile
set toProfileA
with/without static creds.ProfileA
containssource_profile
set toProfileB
.ProfileB
containssource_profile
set toProfileC
and also contains partial static credentials.Profile C
contains credentials.ProfileA
containssource_profile
set toProfileB
and static creds.ProfileB
contains static creds.ProfileB
to call the sts assumeRole and return the credentials from the sts assumeRole call.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.