Skip to content
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

[WIP] Add "duration" option for token command. #75

Closed
wants to merge 1 commit into from
Closed

[WIP] Add "duration" option for token command. #75

wants to merge 1 commit into from

Conversation

kamatama41
Copy link

@kamatama41 kamatama41 commented Apr 13, 2018

This addresses #63
It would make users happy who feel like the 15 mins is too short :)

Signed-off-by: Shinichi Ishimura <shiketaudonko41@gmail.com>
@mattlandis
Copy link
Contributor

Allowing the user to control the length of the validity is a great contribution. We may want to coordinate this with the request.Presign() duration as well.

We may also want to think if there is a way to have the server restrict how long a token can be valid for. An administrator may want to prevent users from using tokens that are too long lived.

Copy link
Contributor

@mattmoyer mattmoyer left a comment

Choose a reason for hiding this comment

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

Looks great, thanks for adding this! I had a few inline comments.

@mattlandis is right that an administrator might want to require shorter validity, since it's basically a cache of an authorization decision and you might not want that to last too long.

There is already a check on the validation side that won't accept tokens with validity longer than 60 seconds, so we'll need to patch that with a maxSessionValidity configuration or something to make this work:
https://github.com/heptio/authenticator/blob/3b5322c58a2345d330eb5cbdfa003e4ebf329ee4/pkg/token/token.go#L284-L287

@@ -67,4 +68,6 @@ func init() {
tokenCmd.Flags().StringP("role", "r", "", "Assume an IAM Role ARN before signing this token")
viper.BindPFlag("role", tokenCmd.Flags().Lookup("role"))
viper.BindEnv("role", "DEFAULT_ROLE")
tokenCmd.Flags().IntP("duration", "d", 15, "Seconds that the token is valid for.")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this flag could be a DurationP which should be a bit cleaner.

@@ -172,8 +172,11 @@ func (g generator) GetWithRole(clusterID string, roleARN string) (string, error)
// if a roleARN was specified, replace the STS client with one that uses
// temporary credentials from that role.
if roleARN != "" {
opt := func(p *stscreds.AssumeRoleProvider) {
p.Duration = time.Duration(duration) * time.Minute
Copy link
Contributor

Choose a reason for hiding this comment

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

The usage message above says "Seconds" but this looks like the argument is interpreted as minutes? I think passing a time.Duration all the way through (rather than int) might be better to avoid this type of confusion.

Copy link
Author

Choose a reason for hiding this comment

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

The usage is wrong. I intended "Minutes" 🙇

@mattlandis
Copy link
Contributor

I have not had a chance to test this but according to the sigv4 signing documentation the maximum length of a signed request being good for is 15 minutes.

We could look at having the authenticator cache the credentials if they are longer than 15 minutes a store some where and when the 1.10 api sends us a request we can reuse the local credentials and make another token good for another 15 minutes. This separates the life time of the MFA session from the life of the token. The downside is the client now needs to manage some sort of state storage.

@kamatama41 kamatama41 changed the title Add "duration" option for token command. [WIP] Add "duration" option for token command. Apr 13, 2018
@kamatama41
Copy link
Author

@mattlandis @mattmoyer
Thank you for reviewing my PR!
I misunderstood that the 15 mins limitation just comes from the duration for the AssumeRoleProvider, but seems to depend on the limitation for signed request as well. (Sorry I had not tested this PR before created.. 🙇) So I think this PR should be closed and the design should be reconsidered. What do you think?

@kamatama41 kamatama41 closed this May 25, 2018
@kamatama41 kamatama41 deleted the make-duration-configurable branch May 25, 2018 06:02
@mhobotpplnet
Copy link

mhobotpplnet commented Aug 7, 2018

This is very annoying when using eks with iam roles and logging into k8 dashboard.
Literally every 15min one would need to re-login.

@bobhenkel
Copy link

bobhenkel commented Aug 14, 2018

Yeah, we use the command below to give users a token to log into the kube dashboard with a token. Works great minus that every 15 minutes their browser session closes on them and they have to get a new token. For kubectl people don't notice that sometimes a command takes longer, but they sure do notice in the web ui when it says session expired/unauthenticated.

heptio-authenticator-aws token -i clustername | jq .status.token -r

@CharlieC3 CharlieC3 mentioned this pull request May 2, 2019
joanayma pushed a commit to joanayma/aws-iam-authenticator that referenced this pull request Aug 11, 2021
…puted-worker-group-count

Use static not computed worker group count
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.

5 participants