diff --git a/go.mod b/go.mod index b58e9943..25363928 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,6 @@ require ( cloud.google.com/go v0.54.0 github.com/Azure/azure-sdk-for-go v32.4.0+incompatible github.com/Azure/go-autorest/autorest v0.5.0 - github.com/Azure/go-autorest/autorest/adal v0.2.0 github.com/Azure/go-autorest/autorest/azure/auth v0.1.0 github.com/Azure/go-autorest/autorest/to v0.2.0 github.com/Azure/go-autorest/autorest/validation v0.1.0 // indirect diff --git a/providers/dns/azure/azure.go b/providers/dns/azure/azure.go index 8e2df135..73b4561a 100644 --- a/providers/dns/azure/azure.go +++ b/providers/dns/azure/azure.go @@ -13,8 +13,6 @@ import ( "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2017-09-01/dns" "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/adal" - "github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/azure/auth" "github.com/Azure/go-autorest/autorest/to" "github.com/go-acme/lego/v3/challenge/dns01" @@ -240,20 +238,17 @@ func toRelativeRecord(domain, zone string) string { func getAuthorizer(config *Config) (autorest.Authorizer, error) { if config.ClientID != "" && config.ClientSecret != "" && config.TenantID != "" { - oauthConfig, err := adal.NewOAuthConfig(azure.PublicCloud.ActiveDirectoryEndpoint, config.TenantID) + credentialsConfig := auth.NewClientCredentialsConfig(config.ClientID, config.ClientSecret, config.TenantID) + + spToken, err := credentialsConfig.ServicePrincipalToken() if err != nil { - return nil, err + return nil, fmt.Errorf("failed to get oauth token from client credentials: %v", err) } - spt, err := adal.NewServicePrincipalToken(*oauthConfig, config.ClientID, config.ClientSecret, azure.PublicCloud.ResourceManagerEndpoint) - if err != nil { - return nil, err - } + spToken.SetSender(config.HTTPClient) - spt.SetSender(config.HTTPClient) - return autorest.NewBearerAuthorizer(spt), nil + return autorest.NewBearerAuthorizer(spToken), nil } - return auth.NewAuthorizerFromEnvironment() }