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

feat: Export expiration as AWS_OKTA_SESSION_EXPIRATION #230

Merged
merged 1 commit into from
Oct 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmd/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,7 @@ func envRun(cmd *cobra.Command, args []string) error {
fmt.Printf("export AWS_SECURITY_TOKEN=%s\n", shellescape.Quote(creds.SessionToken))
}

fmt.Printf("export AWS_OKTA_SESSION_EXPIRATION=%d\n", p.GetExpiration().Unix())

return nil
}
2 changes: 2 additions & 0 deletions cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,8 @@ func execRun(cmd *cobra.Command, args []string) error {
env.Set("AWS_SECURITY_TOKEN", creds.SessionToken)
}

env.Set("AWS_OKTA_SESSION_EXPIRATION", fmt.Sprintf("%d", p.GetExpiration().Unix()))

ecmd := exec.Command(command, commandArgs...)
ecmd.Stdin = os.Stdin
ecmd.Stdout = os.Stdout
Expand Down
4 changes: 4 additions & 0 deletions lib/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ func (p *Provider) Retrieve() (credentials.Value, error) {
return value, nil
}

func (p *Provider) GetExpiration() time.Time {
return p.expires
}

func (p *Provider) getSamlURL() (string, error) {
oktaAwsSAMLUrl, profile, err := p.profiles.GetValue(p.profile, "aws_saml_url")
if err != nil {
Expand Down