Skip to content

Commit

Permalink
Handle nil token returned by ssooidc (#4957)
Browse files Browse the repository at this point in the history
* Handle and Merge possible CreatToken nil value

* Add and Merge changelog for last commit

* Modify and Merge create token result handle scope

---------

Co-authored-by: Tianyi Wang <[email protected]>
  • Loading branch information
wty-Bryant and Tianyi Wang authored Aug 18, 2023
1 parent 18f9283 commit ab7f358
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
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)
9 changes: 9 additions & 0 deletions aws/credentials/ssocreds/token_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ func (p *SSOTokenProvider) refreshToken(token cachedToken) (cachedToken, error)
if err != nil {
return cachedToken{}, fmt.Errorf("unable to refresh SSO token, %v", err)
}
if createResult.ExpiresIn == nil {
return cachedToken{}, fmt.Errorf("missing required field ExpiresIn")
}
if createResult.AccessToken == nil {
return cachedToken{}, fmt.Errorf("missing required field AccessToken")
}
if createResult.RefreshToken == nil {
return cachedToken{}, fmt.Errorf("missing required field RefreshToken")
}

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

Expand Down

0 comments on commit ab7f358

Please sign in to comment.