Fix scopes mutation by cloning original array (#37981)

This commit is contained in:
Sergey Kostrukov 2021-08-18 01:05:14 -07:00 committed by GitHub
parent 050dc7bc8f
commit c6356c5bba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -140,6 +140,12 @@ func (c *managedIdentityTokenRetriever) Init() error {
}
func (c *managedIdentityTokenRetriever) GetAccessToken(ctx context.Context, scopes []string) (*AccessToken, error) {
// Workaround for a bug in Azure SDK which mutates the passed array of scopes
// See details https://github.com/Azure/azure-sdk-for-go/issues/15308
arr := make([]string, len(scopes))
copy(arr, scopes)
scopes = arr
accessToken, err := c.credential.GetToken(ctx, azcore.TokenRequestOptions{Scopes: scopes})
if err != nil {
return nil, err