-
Notifications
You must be signed in to change notification settings - Fork 172
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
AWS: Support source_profile #299
Conversation
Thanks for adding this; looks very useful. I have two general questions, not about a specific part of the code:
|
According to https://docs.aws.amazon.com/cli/latest/topic/config-vars.html#using-aws-iam-roles:
The static credentials part is not something we need to concern ourselves about: Our 'static' credentials are the access keys stored in 1P and because now we support only 1 credential to be mapped to a plugin, users will always use that 1 access key pair, so looking for another pair of static credentials that can be associated to the called profile is out of scope and not supported by us. |
On a second check, I have realised there's a bug in I have opened an issue on was-vault's repo: 99designs/aws-vault#1211 I've also found out self-loops, i.e. profiles which are referencing themselves, are accepted as they would normally work with AWS cli, and it's our tools responsibility to gracefully handle that case. I have introduced a couple of regression tests to cover both roundtrip loop and self-loops. |
I agree that we are indeed achieving the functionality that is described in there. I think it will work for some cases, but I am not sure that we are achieving 100% parity with the CLI when it comes to MFA. Just to check If I understand it correctly, we're only supporting an MFA device on the first role in the chain (i.e. the one that the user refers to). However, it is very well possible that your setup requires the MFA device on a different link that chain. For example, say you have role A and B. The user can assume role A and must use MFA to do so. Role A can assume role B. In a normal config that would look something like:
I am pretty sure this is possible with the AWS CLI, but I am not sure whether this is possible with our shell plugin. The example config in the PR description suggests you have gotten this to work. Are you sure that the MFA device was actually used when using the |
Yes yes, this is exactly what happens in our current version. Roles are chained and each profile uses all information available for retrieving their temporary credentials to pass to the next profile in the chain (so the scenario explained in your example works as you'd expect) |
… if mfa serial and otp are in 1Password item they will be used for all profiles. If only OTP is in 1Password item, it will be used only in profiles that present an mfa serial in config
There still is another edge case matter I'm looking to address: Using mfa authentication in multiple of the chained profiles. Specifically using the same virtual MFA device in multiple profiles in the chain. Using several different MFA devices along the chain of profiles is out of scope because we only support 1 item per plugin. UPDATE: we have decided this use case does not need to be supported, as it's something that wouldn't really occur in practice |
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.
Took a look at the rest of the error messages and left some small questions and notes, but overall I think they look good!
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.
One tiny remark, but overall this looks good to me. Great job, Andy! 🙌
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.
Did a code-review, looks good in broad lines, only a couple nits and a question!
Overview
This change makes so that having
source_profile
in your.aws/config
file doesn't error out and instead behaves as expected.This is the expected behaviour:
Case 1: Only
source_profile
is specified in a profile. --> The source profile is inspected recursively and the right credentials provider is chosen to be used for the current profile.Case 2:
source_profile
is specified, alongside other role/mfa specific information (role_arn
.mfa_serial
etc) --> the source profile is inspected recursively to determine the right provider. This provider is then used as "base" credentials for executing SDK calls to the STS service for retrieving another set of temporary credentials as marked by the other role/mfa specific information present in the current profile.Further aspects regarding recursivity:
source_profile
are handled when parsing the config file using was-vault'sLoadFromProfile
function.Type of change
Related Issue(s)
How To Test
Use a config file that specifies
source_profile
and executeaws sts get-caller-identity --profile <name>
to check that the right credentials were retrieved.Example of config file:
Changelog
AWS Shell Plugin now supports sourcing credentials from another profile.