Skip to content
This repository has been archived by the owner on May 18, 2021. It is now read-only.

Commit

Permalink
Add duration flags for login, increase max assumeRoleDuration to AWS …
Browse files Browse the repository at this point in the history
…limit
  • Loading branch information
reverson committed May 1, 2018
1 parent 15ad703 commit 34aa761
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 14 additions & 3 deletions cmd/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import (

// loginCmd represents the login command
var loginCmd = &cobra.Command{
Use: "login <profile>",
Short: "login will authenticate you through okta and allow you to access your AWS environment through a browser",
RunE: loginRun,
Use: "login <profile>",
Short: "login will authenticate you through okta and allow you to access your AWS environment through a browser",
RunE: loginRun,
PreRun: loginPre,
}

// Stdout is the bool for -stdout
Expand All @@ -29,6 +30,16 @@ func init() {
loginCmd.Flags().BoolVarP(&Stdout, "stdout", "", false, "Print login URL to stdout instead of opening in default browser")
}

func loginPre(cmd *cobra.Command, args []string) {
if err := loadDurationFlagFromEnv(cmd, "session-ttl", "AWS_SESSION_TTL", &sessionTTL); err != nil {
fmt.Fprintln(os.Stderr, "warning: failed to parse duration from AWS_SESSION_TTL")
}

if err := loadDurationFlagFromEnv(cmd, "assume-role-ttl", "AWS_ASSUME_ROLE_TTL", &assumeRoleTTL); err != nil {
fmt.Fprintln(os.Stderr, "warning: failed to parse duration from AWS_ASSUME_ROLE_TTL")
}
}

func loginRun(cmd *cobra.Command, args []string) error {
if len(args) < 1 {
return ErrTooFewArguments
Expand Down
2 changes: 1 addition & 1 deletion lib/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const (
MaxSessionDuration = time.Hour * 36
MinSessionDuration = time.Minute * 15
MinAssumeRoleDuration = time.Minute * 15
MaxAssumeRoleDuration = time.Hour
MaxAssumeRoleDuration = time.Hour * 12

DefaultSessionDuration = time.Hour * 4
DefaultAssumeRoleDuration = time.Minute * 15
Expand Down

0 comments on commit 34aa761

Please sign in to comment.