@@ -11,12 +11,15 @@ import (
11
11
"time"
12
12
13
13
"github.com/Azure/azure-pipeline-go/pipeline"
14
+ "github.com/Azure/azure-sdk-for-go/sdk/azcore"
15
+ "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud"
16
+ "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
14
17
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage"
15
18
"github.com/Azure/azure-storage-blob-go/azblob"
16
19
"github.com/Azure/go-autorest/autorest"
17
20
autorestazure "github.com/Azure/go-autorest/autorest/azure"
18
- "github.com/Azure/go-autorest/autorest/azure/auth"
19
21
"github.com/Azure/go-autorest/autorest/to"
22
+ "github.com/jongio/azidext/go/azidext"
20
23
21
24
corev1 "k8s.io/api/core/v1"
22
25
"k8s.io/apimachinery/pkg/api/errors"
@@ -299,16 +302,30 @@ func (d *driver) storageAccountsClient(cfg *Azure, environment autorestazure.Env
299
302
if d .authorizer != nil {
300
303
storageAccountsClient .Authorizer = d .authorizer
301
304
} else {
302
- clientCredentialsConfig := auth .NewClientCredentialsConfig (cfg .ClientID , cfg .ClientSecret , cfg .TenantID )
303
- clientCredentialsConfig .Resource = environment .TokenAudience
304
- clientCredentialsConfig .AADEndpoint = environment .ActiveDirectoryEndpoint
305
-
306
- auth , err := clientCredentialsConfig .Authorizer ()
305
+ cloudConfig := cloud.Configuration {
306
+ ActiveDirectoryAuthorityHost : environment .ActiveDirectoryEndpoint ,
307
+ Services : map [cloud.ServiceName ]cloud.ServiceConfiguration {
308
+ cloud .ResourceManager : {
309
+ Audience : environment .TokenAudience ,
310
+ Endpoint : environment .ResourceManagerEndpoint ,
311
+ },
312
+ },
313
+ }
314
+ options := azidentity.ClientSecretCredentialOptions {
315
+ ClientOptions : azcore.ClientOptions {
316
+ Cloud : cloudConfig ,
317
+ },
318
+ }
319
+ cred , err := azidentity .NewClientSecretCredential (cfg .TenantID , cfg .ClientID , cfg .ClientSecret , & options )
307
320
if err != nil {
308
321
return storage.AccountsClient {}, err
309
322
}
323
+ scope := environment .TokenAudience
324
+ if ! strings .HasSuffix (scope , "/.default" ) {
325
+ scope += "/.default"
326
+ }
310
327
311
- storageAccountsClient .Authorizer = auth
328
+ storageAccountsClient .Authorizer = azidext . NewTokenCredentialAdapter ( cred , [] string { scope })
312
329
}
313
330
314
331
if d .sender != nil {
0 commit comments