Skip to content

Commit

Permalink
Fix export lookup values when exporting credentials (#578)
Browse files Browse the repository at this point in the history
* Fix export lookup values when exporting credentials

When `session` is present on the config it should be where
we get the `start_url` and `region`. Most configs will not
have said config under `profile` if they have a session block.
Session block takes priority for the configuration as it's considered
as it's connecting profiles together.

Fix for #577

* Adjust the logic for override

Override the sso_start_url if it's empty and have a proper session
block.
  • Loading branch information
cedieio committed Dec 27, 2023
1 parent cb1e905 commit a7bbfd3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pkg/cfaws/ssotoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,22 @@ type SSOPlainTextOut struct {
// we'll allow users to export a plaintext token from their keychain for compatibility
// purposes with other AWS tools.
func CreatePlainTextSSO(awsConfig config.SharedConfig, token *securestorage.SSOToken) *SSOPlainTextOut {
ssoRegion := awsConfig.SSORegion
if ssoRegion == "" && awsConfig.SSOSession != nil {
ssoRegion = awsConfig.SSOSession.SSORegion
}

ssoStartURL := awsConfig.SSOStartURL
if ssoStartURL == "" && awsConfig.SSOSession != nil {
ssoStartURL = awsConfig.SSOSession.SSOStartURL
}

return &SSOPlainTextOut{
AccessToken: token.AccessToken,
ExpiresAt: token.Expiry.Format(time.RFC3339),
Region: awsConfig.Region,
Region: ssoRegion,
SSOSessionName: awsConfig.SSOSessionName,
StartUrl: awsConfig.SSOStartURL,
StartUrl: ssoStartURL,
}
}

Expand Down

0 comments on commit a7bbfd3

Please sign in to comment.