-
Notifications
You must be signed in to change notification settings - Fork 426
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
Support getting tokens from an IAM Role requiring MFA #42
Conversation
Signed-off-by: Gijs Kunze <gijs@usabilla.com>
Great! LGTM |
I should note that since Another issue is that this will mean that the user will need to enter an MFA code for every kubectl command they want to execute. Including having to wait 30 seconds between commands for a new code to be generated as you can't use the same one twice. This is of course not the best user experience. It might be better if there was some caching of the pre-signed url on the client side machine, only generating a new token when the url is about to expire... |
@gwkunze Noted, the implementation of this proposal kubernetes/community#1503 kubernetes/enhancements#541 which is how heptio authenticator will be exec'd by kubectl, will have to make sure the exec'd process properly inherits stdin from kubectl. Its a similar situation for binaries that have a
Caching is also be handled by that proposal, but perhaps we can wait until the proposal is finalized before moving forward with this.
|
@gwkunze thanks for this! We run with MFA-restricted IAM roles here too so this is very welcome. I'd still like to merge this, but I agree with @nckturner re:
If it's helpful, I've been using https://github.com/99designs/aws-vault to do the MFA dance. |
If you don't mind, do a |
Signed-off-by: Gijs Kunze <gijs@usabilla.com>
Apologies for the late update. |
@mattlandis @mattmoyer @nckturner Hi, this is a friendly reminder towards merging this great work. Given the commit is now signed-off and it is already LGTMed, probably you want to merge this? |
I want to check that this works properly with the new 1.10 auth provider changes in client-go before we merge this change in. |
Rereading @gwkunze's comment, all the issues he mentioned apply for the 1.10 auth provider because the aws sdk prints the prompt to enter your MFA code on stdout, which in the 1.10 exec based system is reserved for the formatted json token output. Also, I'm not sure why I missed this initially but prompting to stderr is exactly what we should do. I propose we merge this change, tag and branch for kubernetes 1.9, then merge 1.10 support and create an issue in this repository for the broken 1.10 MFA functionality. We can then look into fixing that with a custom AssumeRoleProvider or something similar. Note that we will need the fix in the 1.9 branch as well. |
And prompting every kubectl invocation would be annoying, you're right, we should look into caching client side beyond the lifetime of the authenticator. |
It looks like providing a custom TokenProvider function for stderr vs. stdout would be pretty easy: It looks like if we just replace the func StdinStderrTokenProvider() (string, error) {
var v string
fmt.Fprint(os.Stderr, "Assume Role MFA token code: ")
_, err := fmt.Scanln(&v)
return v, err
} |
Great, let's merge this PR and get a fix in. |
Adding the AssumeRoleTokenProvider allows accounts with MFA to also request a token. Instead of getting an error:
The app asks the user for an mfa code: