Skip to content

Commit 2f0802d

Browse files
committed
fix: use duration value set from cli
enable retrieval from secretStore for both cred types
1 parent cbd5b56 commit 2f0802d

File tree

5 files changed

+6
-8
lines changed

5 files changed

+6
-8
lines changed

cmd/saml.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var (
1111
principalArn string
1212
acsUrl string
1313
role string
14-
duration int
14+
duration int64
1515
samlCmd = &cobra.Command{
1616
Use: "saml <SAML ProviderUrl>",
1717
Short: "Get AWS credentials and out to stdout",
@@ -24,7 +24,7 @@ func init() {
2424
samlCmd.PersistentFlags().StringVarP(&providerUrl, "provider", "p", "", "Saml Entity StartSSO Url")
2525
samlCmd.PersistentFlags().StringVarP(&principalArn, "principal", "", "", "Principal Arn of the SAML IdP in AWS")
2626
samlCmd.PersistentFlags().StringVarP(&acsUrl, "acsurl", "a", "https://signin.aws.amazon.com/saml", "Override the default ACS Url, used for checkin the post of the SAMLResponse")
27-
samlCmd.PersistentFlags().IntVarP(&duration, "max-duration", "d", 900, "Override default max session duration, in seconds, of the role session [900-43200]")
27+
samlCmd.PersistentFlags().Int64VarP(&duration, "max-duration", "d", 900, "Override default max session duration, in seconds, of the role session [900-43200]")
2828
rootCmd.AddCommand(samlCmd)
2929
}
3030

internal/auth/awssts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func LoginStsSaml(samlResponse string, role *util.AWSRole) (*util.AWSCredentials
3333
PrincipalArn: aws.String(role.PrincipalARN), // Required
3434
RoleArn: aws.String(role.RoleARN), // Required
3535
SAMLAssertion: aws.String(samlResponse), // Required
36-
DurationSeconds: aws.Int64(int64(role.Duration)),
36+
DurationSeconds: aws.Int64(role.Duration),
3737
}
3838

3939
resp, err := svc.AssumeRoleWithSAML(params)

internal/auth/saml.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ func GetSamlCreds(conf config.SamlConfig) {
2121
var err error
2222

2323
// Try to reuse stored credential in secret
24-
if !conf.BaseConfig.StoreInProfile {
25-
awsCreds, err = secretStore.AWSCredential()
26-
}
24+
awsCreds, err = secretStore.AWSCredential()
2725

2826
if !util.IsValid(awsCreds) || err != nil {
2927
webBrowser = web.New()

internal/config/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ type SamlConfig struct {
1919
ProviderUrl string
2020
PrincipalArn string
2121
AcsUrl string
22-
Duration int
22+
Duration int64
2323
}

internal/util/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ type AWSRole struct {
1717
RoleARN string
1818
PrincipalARN string
1919
Name string
20-
Duration int
20+
Duration int64
2121
}

0 commit comments

Comments
 (0)