Skip to content

Commit

Permalink
fix(auth/oauth2adapt): copy map in tokenSourceAdapter.Token (#11164)
Browse files Browse the repository at this point in the history
fixes: #11161
  • Loading branch information
quartzmo authored Nov 21, 2024
1 parent 117748b commit 8cb0cbc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions auth/oauth2adapt/oauth2adapt.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,13 @@ func (ts *tokenSourceAdapter) Token() (*oauth2.Token, error) {
Expiry: tok.Expiry,
}
// Preserve token metadata.
metadata := tok.Metadata
if metadata != nil {
m := tok.Metadata
if m != nil {
// Copy map to avoid concurrent map writes error (#11161).
metadata := make(map[string]interface{}, len(m)+2)
for k, v := range m {
metadata[k] = v
}
// Append compute token metadata in converted form.
if val, ok := metadata[authTokenSourceKey].(string); ok && val != "" {
metadata[oauth2TokenSourceKey] = val
Expand Down

0 comments on commit 8cb0cbc

Please sign in to comment.