Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Allow Role selection #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

endemics
Copy link
Contributor

When there are multiple values to <saml2:Attribute Name="https://aws.amazon.com/SAML/Attributes/Role">, instead of blindly taking the first one, prompt the user for the one she wants.

This is needed if you have multiple targets and a 1:1 mapping between a Cross-Account role and a target role.

@erickt
Copy link

erickt commented Sep 18, 2017

Any chance this, and the other outstanding PRs, be reviewed? They all seem super helpful.

@erickt
Copy link

erickt commented Oct 24, 2017

I just tried your PR out, and there's a bit of an issue with it, at least with a bastion account and cross accounts. oktad needs me to configure a profile in ~/.aws/config, where I need to specify which role I want to assume. Your patch prompts me to pick the role, where I need to pick the role I already configured in ~/.aws/config. Could you change this PR to look up the role in the config file?

@endemics
Copy link
Contributor Author

@erickt I have actually implemented something like that in endemics@124b00f but haven't created a PR yet.

You can pull the code from https://github.com/endemics/oktad, the master branch has my 3 patches (that's the one we're using internally).

@endemics endemics mentioned this pull request Dec 11, 2017
@@ -119,3 +128,65 @@ func assumeDestinationRole(acfg AwsConfig, creds *credentials.Credentials) (*cre

return mCreds, *res.Credentials.Expiration, nil
}

func splitSamlProviderArns(arns string) (*SamlProviderArns, error) {
Copy link

Choose a reason for hiding this comment

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

Not a big deal, but nitpicking: no real reason for this to return a pointer to this struct; should just return the struct value.

Copy link

Choose a reason for hiding this comment

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

(I know that the other code in this project does not follow this guideline well, but that's something I'm hoping to correct...)

@ghost
Copy link

ghost commented Dec 14, 2017

I like the idea of this especially because we're talking about moving to this model for our AWS accounts rather than relying on ~/.aws/config. Less burden on users to set up the profiles for each account in that setup.

That said: maybe this should only prompt for account selection in the event that a user hasn't provided a profile/account to use? Then this code could try to find the name supplied in the SAML response or ~/.aws/config.

There's also potential to retrieve a list of accounts to check against using the AWS Organizations API as well, though that requires permissions to your Organizations account, at least in our case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants