@@ -26,23 +26,30 @@ import (
26
26
)
27
27
28
28
const (
29
- azureAuthorityHost = "AZURE_AUTHORITY_HOST"
30
- azureClientCertificatePassword = "AZURE_CLIENT_CERTIFICATE_PASSWORD"
31
- azureClientCertificatePath = "AZURE_CLIENT_CERTIFICATE_PATH"
32
- azureClientID = "AZURE_CLIENT_ID"
33
- azureClientSecret = "AZURE_CLIENT_SECRET"
34
- azureFederatedTokenFile = "AZURE_FEDERATED_TOKEN_FILE"
35
- azurePassword = "AZURE_PASSWORD"
36
- azureRegionalAuthorityName = "AZURE_REGIONAL_AUTHORITY_NAME"
37
- azureTenantID = "AZURE_TENANT_ID"
38
- azureUsername = "AZURE_USERNAME"
29
+ azureAdditionallyAllowedTenants = "AZURE_ADDITIONALLY_ALLOWED_TENANTS"
30
+ azureAuthorityHost = "AZURE_AUTHORITY_HOST"
31
+ azureClientCertificatePassword = "AZURE_CLIENT_CERTIFICATE_PASSWORD"
32
+ azureClientCertificatePath = "AZURE_CLIENT_CERTIFICATE_PATH"
33
+ azureClientID = "AZURE_CLIENT_ID"
34
+ azureClientSecret = "AZURE_CLIENT_SECRET"
35
+ azureFederatedTokenFile = "AZURE_FEDERATED_TOKEN_FILE"
36
+ azurePassword = "AZURE_PASSWORD"
37
+ azureRegionalAuthorityName = "AZURE_REGIONAL_AUTHORITY_NAME"
38
+ azureTenantID = "AZURE_TENANT_ID"
39
+ azureUsername = "AZURE_USERNAME"
39
40
40
41
organizationsTenantID = "organizations"
41
42
developerSignOnClientID = "04b07795-8ddb-461a-bbee-02f9e1bf7b46"
42
43
defaultSuffix = "/.default"
43
44
tenantIDValidationErr = "invalid tenantID. You can locate your tenantID by following the instructions listed here: https://docs.microsoft.com/partner-center/find-ids-and-domain-names"
44
45
)
45
46
47
+ var (
48
+ // capability CP1 indicates the client application is capable of handling CAE claims challenges
49
+ cp1 = []string {"CP1" }
50
+ disableCP1 = strings .ToLower (os .Getenv ("AZURE_IDENTITY_DISABLE_CP1" )) == "true"
51
+ )
52
+
46
53
var getConfidentialClient = func (clientID , tenantID string , cred confidential.Credential , co * azcore.ClientOptions , additionalOpts ... confidential.Option ) (confidentialClient , error ) {
47
54
if ! validTenantID (tenantID ) {
48
55
return confidential.Client {}, errors .New (tenantIDValidationErr )
@@ -51,16 +58,19 @@ var getConfidentialClient = func(clientID, tenantID string, cred confidential.Cr
51
58
if err != nil {
52
59
return confidential.Client {}, err
53
60
}
61
+ authority := runtime .JoinPaths (authorityHost , tenantID )
54
62
o := []confidential.Option {
55
- confidential .WithAuthority (runtime .JoinPaths (authorityHost , tenantID )),
56
63
confidential .WithAzureRegion (os .Getenv (azureRegionalAuthorityName )),
57
64
confidential .WithHTTPClient (newPipelineAdapter (co )),
58
65
}
66
+ if ! disableCP1 {
67
+ o = append (o , confidential .WithClientCapabilities (cp1 ))
68
+ }
59
69
o = append (o , additionalOpts ... )
60
70
if strings .ToLower (tenantID ) == "adfs" {
61
71
o = append (o , confidential .WithInstanceDiscovery (false ))
62
72
}
63
- return confidential .New (clientID , cred , o ... )
73
+ return confidential .New (authority , clientID , cred , o ... )
64
74
}
65
75
66
76
var getPublicClient = func (clientID , tenantID string , co * azcore.ClientOptions , additionalOpts ... public.Option ) (public.Client , error ) {
@@ -71,18 +81,18 @@ var getPublicClient = func(clientID, tenantID string, co *azcore.ClientOptions,
71
81
if err != nil {
72
82
return public.Client {}, err
73
83
}
74
-
75
84
o := []public.Option {
76
85
public .WithAuthority (runtime .JoinPaths (authorityHost , tenantID )),
77
86
public .WithHTTPClient (newPipelineAdapter (co )),
78
87
}
88
+ if ! disableCP1 {
89
+ o = append (o , public .WithClientCapabilities (cp1 ))
90
+ }
79
91
o = append (o , additionalOpts ... )
80
92
if strings .ToLower (tenantID ) == "adfs" {
81
93
o = append (o , public .WithInstanceDiscovery (false ))
82
94
}
83
- return public .New (clientID ,
84
- o ... ,
85
- )
95
+ return public .New (clientID , o ... )
86
96
}
87
97
88
98
// setAuthorityHost initializes the authority host for credentials. Precedence is:
0 commit comments