Skip to content

Commit

Permalink
fix: update AAD and Azure endpoints using Cloud from cpConfig (#1271)
Browse files Browse the repository at this point in the history
* set AAD endpoint using Cloud provider from cpConfig

* add resource endpoint
  • Loading branch information
akshaysngupta authored Sep 29, 2021
1 parent 3561bb3 commit 0646582
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/azure/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

n "github.com/Azure/azure-sdk-for-go/services/network/mgmt/2021-03-01/network"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/azure/auth"
"k8s.io/klog/v2"

Expand Down Expand Up @@ -40,6 +41,12 @@ func getAuthorizer(authLocation string, useManagedidentity bool, cpConfig *Cloud
if !useManagedidentity && cpConfig != nil {
klog.V(1).Info("Creating authorizer using Cluster Service Principal.")
credAuthorizer := auth.NewClientCredentialsConfig(cpConfig.ClientID, cpConfig.ClientSecret, cpConfig.TenantID)

// Set active directory endpoint using environment
azureEnv, _ := azure.EnvironmentFromName(cpConfig.Cloud)
credAuthorizer.AADEndpoint = azureEnv.ActiveDirectoryEndpoint
credAuthorizer.Resource = azureEnv.ResourceManagerEndpoint

return credAuthorizer.Authorizer()
}

Expand Down

0 comments on commit 0646582

Please sign in to comment.