Skip to content

Commit

Permalink
Add the time when it will expire to debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
mikutas committed Dec 20, 2021
1 parent f872b40 commit 1eb5eed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions cmd/saml2aws/commands/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ func Login(loginFlags *flags.LoginExecFlags) error {
return nil
}

if !sharedCreds.Expired() && !loginFlags.Force {
logger.Debug("Credentials are not expired. Skipping.")
expired, expireTime := sharedCreds.Expired()
if !expired && !loginFlags.Force {
logger.Debug("Credentials are not expired. It will expire at ", expireTime, ". Skipping.")
previousCreds, err := sharedCreds.Load()
if err != nil {
log.Println("Unable to load cached credentials.")
Expand Down
6 changes: 3 additions & 3 deletions pkg/awsconfig/awsconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ func (p *CredentialsProvider) Load() (*AWSCredentials, error) {
}

// Expired checks if the current credentials are expired
func (p *CredentialsProvider) Expired() bool {
func (p *CredentialsProvider) Expired() (bool, *time.Time) {
creds, err := p.Load()
if err != nil {
return true
return true, nil
}

return time.Now().After(creds.Expires)
return time.Now().After(creds.Expires), &creds.Expires
}

// ensureConfigExists verify that the config file exists
Expand Down

0 comments on commit 1eb5eed

Please sign in to comment.