common-fate / granted

The easiest way to access your cloud.
https://granted.dev
MIT License
957 stars 90 forks source link

assume option --export-sso-token causes panic: runtime error #563

Closed cedieio closed 6 months ago

cedieio commented 7 months ago

The recent feature for assume --export-sso-token is causing panic when being run.

This is due to cred-exporter.go not having the correct key when finding the cached token below. It should have the correct key for finding the token.

-cachedToken := secureSSOTokenStorage.GetValidSSOToken(profile.AWSConfig.SSOStartURL)
+tokenKey := profile.AWSConfig.SSOStartURL + profile.AWSConfig.SSOSessionName
+cachedToken := secureSSOTokenStorage.GetValidSSOToken(tokenKey)

Another is when finding the plain text sso token is using the tokenKey := profile.AWSConfig.SSOStartURL + profile.AWSConfig.SSOSessionName which should not be the case as the token is being queried using the profile.AWSConfig.SSOStartURL

it should be

-plainTextToken := GetValidSSOTokenFromPlaintextCache(ssoTokenKey)
+plainTextToken := GetValidSSOTokenFromPlaintextCache(profile.AWSConfig.SSOStartURL)