Skip to content

Allow users to assume MFA device is already configured #68

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

Merged
merged 3 commits into from
Jun 30, 2020

Conversation

chrisgilmerproj
Copy link

@chrisgilmerproj chrisgilmerproj commented Jun 30, 2020

This was a useful modification for MilMove where new credentials were provided after the MFA was already set up. Passing the flag --no-mfa will retrieve the existing MFA serial number instead of creating and enabling a new device.

Pivotal Story:

Notes: This could possibly be a separate subcommand like setup-new-aws-user update-creds but for now it feels better to keep things simplified until we know more about the workflow around setting up accounts.

@chrisgilmerproj chrisgilmerproj requested a review from a team June 30, 2020 18:03
@chrisgilmerproj chrisgilmerproj self-assigned this Jun 30, 2020
@chrisgilmerproj
Copy link
Author

chrisgilmerproj commented Jun 30, 2020

Testing:

go run ./cmd/ setup --iam-user cgilmer-delete-me --iam-role engineer --aws-profile delete-id --aws-account-id REDACTED --no-mfa
Checking whether profile "delete-id-base" exists in AWS config file
Checking whether profile "delete-id" exists in AWS config file
Enter Access Key ID: REDACTED
Enter Secret Access Key: REDACTED
Added credentials to profile "delete-id-base" in vault
Getting the existing MFA device...
Updating the AWS config file: /Users/cgilmer/.aws/config
Victory!

if len(mfaDeviceOutput.MFADevices) == 0 {
return errors.New("no MFA devices registered")
}
mfaDevice := mfaDeviceOutput.MFADevices[0]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean you're taking the first device? Is it possible to have more than 1? How do you support a user who wants to use an MFA device that isn't the first one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't think the setup supported more than one. Now I'm curious.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, there's room for several in the api return but in practice I've never ever seen more than one. I assume it's some kind of internal tooling where they can provision a new one while the old one is being deprovisioned.

Regardless, I think it's a difficult user experience to try to figure out which one the user wants to select given the output of the API. So it's probably safe to assume the first one is the right one and all other edge cases will not be handled.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For safety I added in an error if more than one is returned.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Copy link
Contributor

@mdawn mdawn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@chrisgilmerproj chrisgilmerproj merged commit 946a9d3 into master Jun 30, 2020
@chrisgilmerproj chrisgilmerproj deleted the cg_no_mfa branch June 30, 2020 21:46
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.

4 participants