@@ -21,6 +21,7 @@ import (
21
21
"crypto/x509"
22
22
"fmt"
23
23
"io/ioutil"
24
+ "strings"
24
25
25
26
"github.com/Azure/go-autorest/autorest/adal"
26
27
"github.com/Azure/go-autorest/autorest/azure"
@@ -31,6 +32,8 @@ import (
31
32
var (
32
33
// ErrorNoAuth indicates that no credentials are provided.
33
34
ErrorNoAuth = fmt .Errorf ("no credentials provided for Azure cloud provider" )
35
+ // Tenenatid value for Azure Stack ADFS case.
36
+ ADFSIdentitySystem = "ADFS"
34
37
)
35
38
36
39
// AzureAuthConfig holds auth related part of cloud config
@@ -55,10 +58,19 @@ type AzureAuthConfig struct {
55
58
UserAssignedIdentityID string `json:"userAssignedIdentityID,omitempty" yaml:"userAssignedIdentityID,omitempty"`
56
59
// The ID of the Azure Subscription that the cluster is deployed in
57
60
SubscriptionID string `json:"subscriptionId,omitempty" yaml:"subscriptionId,omitempty"`
61
+ // Identity system value for the deployment. This gets populate for Azure Stack case.
62
+ IdentitySystem string `json:"identitySystem,omitempty" yaml:"identitySystem,omitempty"`
58
63
}
59
64
60
65
// GetServicePrincipalToken creates a new service principal token based on the configuration
61
66
func GetServicePrincipalToken (config * AzureAuthConfig , env * azure.Environment ) (* adal.ServicePrincipalToken , error ) {
67
+ var tenantId string
68
+ if strings .EqualFold (config .IdentitySystem , ADFSIdentitySystem ) {
69
+ tenantId = "adfs"
70
+ } else {
71
+ tenantId = config .TenantID
72
+ }
73
+
62
74
if config .UseManagedIdentityExtension {
63
75
klog .V (2 ).Infoln ("azure: using managed identity extension to retrieve access token" )
64
76
msiEndpoint , err := adal .GetMSIVMEndpoint ()
@@ -77,7 +89,7 @@ func GetServicePrincipalToken(config *AzureAuthConfig, env *azure.Environment) (
77
89
env .ServiceManagementEndpoint )
78
90
}
79
91
80
- oauthConfig , err := adal .NewOAuthConfig (env .ActiveDirectoryEndpoint , config . TenantID )
92
+ oauthConfig , err := adal .NewOAuthConfig (env .ActiveDirectoryEndpoint , tenantId )
81
93
if err != nil {
82
94
return nil , fmt .Errorf ("creating the OAuth config: %v" , err )
83
95
}
0 commit comments