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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle nil token returned by ssooidc #4957

Merged
merged 3 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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 CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
### SDK Enhancements

### SDK Bugs
* `aws/credentials/ssocreds`: Modify sso token provider logic to handle possible nil val returned by CreateToken.
* Fixes [4947](https://github.com/aws/aws-sdk-go/issues/4947)
4 changes: 4 additions & 0 deletions aws/credentials/ssocreds/token_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ func (p *SSOTokenProvider) refreshToken(token cachedToken) (cachedToken, error)
if err != nil {
return cachedToken{}, fmt.Errorf("unable to refresh SSO token, %v", err)
}
if createResult == nil || createResult.ExpiresIn == nil ||
createResult.AccessToken == nil || createResult.RefreshToken == nil {
return cachedToken{}, fmt.Errorf("CreateToken returned some nil val without err")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should limit the scope of this change e.g.

if createResult.ExpiresIn == nil {
    return cachedToken{}, fmt.Errorf("missing required field ExpiresIn")
}

}

expiresAt := nowTime().Add(time.Duration(*createResult.ExpiresIn) * time.Second)

Expand Down