Skip to content

Commit 532f2ab

Browse files
authored
Merge pull request #176 from wiz-sec/guy/server-and-expiry
Guy/server and expiry
2 parents 0ea5e10 + 863b124 commit 532f2ab

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

cli/add.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"log"
66
"os"
7+
"time"
78

89
"github.com/99designs/aws-vault/v7/prompt"
910
"github.com/99designs/aws-vault/v7/vault"
@@ -50,7 +51,8 @@ func ConfigureAddCommand(app *kingpin.Application, a *AwsVault) {
5051
}
5152

5253
func AddCommand(input AddCommandInput, keyring keyring.Keyring, awsConfigFile *vault.ConfigFile) error {
53-
var accessKeyID, secretKey, sessionToken string
54+
var accessKeyID, secretKey, sessionToken, expiration string
55+
var expires time.Time
5456

5557
p, _ := awsConfigFile.ProfileSection(input.ProfileName)
5658
if p.SourceProfile != "" {
@@ -68,6 +70,15 @@ func AddCommand(input AddCommandInput, keyring keyring.Keyring, awsConfigFile *v
6870
if sessionToken = os.Getenv("AWS_SESSION_TOKEN"); sessionToken == "" {
6971
return fmt.Errorf("Missing value for AWS_SESSION_TOKEN")
7072
}
73+
if expiration = os.Getenv("EXPIRATION"); expiration == "" {
74+
return fmt.Errorf("Missing value for EXPIRATION")
75+
}
76+
77+
var err error
78+
expires, err = time.Parse(time.RFC3339, expiration)
79+
if err != nil {
80+
return fmt.Errorf("Error parsing EXPIRATION: %w", err)
81+
}
7182
} else {
7283
var err error
7384
if accessKeyID, err = prompt.TerminalPrompt("Enter Access Key ID: "); err != nil {
@@ -78,7 +89,7 @@ func AddCommand(input AddCommandInput, keyring keyring.Keyring, awsConfigFile *v
7889
}
7990
}
8091

81-
creds := aws.Credentials{AccessKeyID: accessKeyID, SecretAccessKey: secretKey, SessionToken: sessionToken}
92+
creds := aws.Credentials{AccessKeyID: accessKeyID, SecretAccessKey: secretKey, SessionToken: sessionToken, Expires: expires}
8293

8394
ckr := &vault.CredentialKeyring{Keyring: keyring}
8495
if err := ckr.Set(input.ProfileName, creds); err != nil {

cli/exec.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ func (input ExecCommandInput) validate() error {
4343
if input.StartEc2Server && input.JSONDeprecated {
4444
return fmt.Errorf("Can't use --ec2-server with --json")
4545
}
46-
if input.StartEc2Server && input.NoSession {
47-
return fmt.Errorf("Can't use --ec2-server with --no-session")
48-
}
4946
if input.StartEcsServer && input.JSONDeprecated {
5047
return fmt.Errorf("Can't use --ecs-server with --json")
5148
}

0 commit comments

Comments
 (0)