Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Fix SSO token lookup keys #565

Merged
merged 2 commits into from
Dec 16, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/cfaws/assumer_aws_sso.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (c *Profile) SSOLogin(ctx context.Context, configOpts ConfigOpts) (aws.Cred
secureSSOTokenStorage := securestorage.NewSecureSSOTokenStorage()
cachedToken := secureSSOTokenStorage.GetValidSSOToken(ssoTokenKey)
// check if profile has a valid plaintext sso access token
plainTextToken := GetValidSSOTokenFromPlaintextCache(ssoTokenKey)
plainTextToken := GetValidSSOTokenFromPlaintextCache(rootProfile.SSOStartURL())

// store token to storage to avoid multiple logins
if plainTextToken != nil {
Expand Down
5 changes: 3 additions & 2 deletions pkg/cfaws/cred-exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ func ExportCredsToProfile(profileName string, creds aws.Credentials) error {
// ExportAccessTokenToCache will export access tokens to ~/.aws/sso/cache
func ExportAccessTokenToCache(profile *Profile) error {
secureSSOTokenStorage := securestorage.NewSecureSSOTokenStorage()
// Find the access token for the SSOStartURL
cachedToken := secureSSOTokenStorage.GetValidSSOToken(profile.AWSConfig.SSOStartURL)
// Find the access token for the SSOStartURL and SSOSessionName
tokenKey := profile.AWSConfig.SSOStartURL + profile.AWSConfig.SSOSessionName
cachedToken := secureSSOTokenStorage.GetValidSSOToken(tokenKey)
ssoPlainTextOut := CreatePlainTextSSO(profile.AWSConfig, cachedToken)
err := ssoPlainTextOut.DumpToCacheDirectory()

Expand Down