Skip to content

Commit 9ce8cd8

Browse files
JonathanCrdCopilot
andauthored
[Identity] Rename BrokerAuthenticationCredential as BrokerCredential (Azure#51612)
* rename symbols and methods * Update Changelog and Troubleshooting * Update sdk/identity/Azure.Identity/TROUBLESHOOTING.md Co-authored-by: Copilot <[email protected]> * Switch Azure.Identity reference to project reference Replaces the Azure.Identity package reference with a project reference to Azure.Identity.csproj. This is a temporary change until the package is available with the new BrokerCredential name. --------- Co-authored-by: Copilot <[email protected]>
1 parent 2129efc commit 9ce8cd8

File tree

8 files changed

+19
-16
lines changed

8 files changed

+19
-16
lines changed

sdk/identity/Azure.Identity.Broker/src/Azure.Identity.Broker.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1414
</PropertyGroup>
1515
<ItemGroup>
16-
<PackageReference Include="Azure.Identity" VersionOverride="1.15.0-beta.1" />
16+
<!--Change this back to a package reference when the package is available with the new BrokerCredential name.-->
17+
<!--<PackageReference Include="Azure.Identity" VersionOverride="1.15.0-beta.1" />-->
18+
<ProjectReference Include="..\..\Azure.Identity\src\Azure.Identity.csproj"/>
1719
<PackageReference Include="Microsoft.Identity.Client.Broker" />
1820
</ItemGroup>
1921
</Project>

sdk/identity/Azure.Identity.Broker/tests/DefaultAzureCredentialFactoryTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static IEnumerable<object[]> CredSelection()
2525
yield return new object[] { Constants.WorkloadIdentityCredential };
2626
yield return new object[] { Constants.ManagedIdentityCredential };
2727
yield return new object[] { Constants.InteractiveBrowserCredential };
28-
yield return new object[] { Constants.BrokerAuthenticationCredential };
28+
yield return new object[] { Constants.BrokerCredential };
2929
}
3030

3131
#pragma warning disable CS0618 // Type or member is obsolete
@@ -97,7 +97,7 @@ public void ValidateDefaultAzureCredentialAZURE_TOKEN_CREDENTIALS_Honored_WithBr
9797
{
9898
Assert.IsTrue(chain.Single(cred => cred is InteractiveBrowserCredential) is InteractiveBrowserCredential);
9999
}
100-
else if (credSelection == Constants.BrokerAuthenticationCredential)
100+
else if (credSelection == Constants.BrokerCredential)
101101
{
102102
Assert.IsTrue(chain.Single(cred => cred is InteractiveBrowserCredential) is InteractiveBrowserCredential);
103103
}

sdk/identity/Azure.Identity.Broker/tests/DevelopmentBrokerOptionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void TryCreateDevelopmentBrokerOptionsFromCredentialFactory()
2121
{
2222
var factory = new DefaultAzureCredentialFactory(new DefaultAzureCredentialOptions());
2323
DefaultAzureCredentialFactory.TryCreateDevelopmentBrokerOptions(out var options);
24-
var cred = factory.CreateBrokerAuthenticationCredential(options);
24+
var cred = factory.CreateBrokerCredential(options);
2525
try
2626
{
2727
cred.GetToken(new TokenRequestContext(new[] { "https://management.azure.com/.default" }), default);

sdk/identity/Azure.Identity/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- Tenant ID comparisons in credential options are now case-insensitive. This affects `AdditionallyAllowedTenants` values which will now be matched against tenant IDs without case sensitivity, making the authentication more resilient to case differences in tenant IDs returned from WWW-Authenticate challenges ([#51693](https://github.com/Azure/azure-sdk-for-net/issues/51693)).
2121

2222
### Other Changes
23+
- `BrokerAuthenticationCredential` has been renamed as `BrokerCredential`.
2324

2425
- Added the `EditorBrowsable(Never)` attribute to property `VisualStudioCodeTenantId` as `TenantId` is preferred. The `VisualStudioCodeTenantId` property exists only to provide backwards compatibility.
2526

sdk/identity/Azure.Identity/TROUBLESHOOTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ DefaultAzureCredentialOptions options = new
125125
|---|---|---|
126126
|`CredentialUnavailableException` raised with message. "DefaultAzureCredential failed to retrieve a token from the included credentials."|All credentials in the `DefaultAzureCredential` chain failed to retrieve a token, each throwing a `CredentialUnavailableException`.|<ul><li>[Enable logging](#enable-and-configure-logging) to verify the credentials being tried, and get further diagnostic information.</li><li>Consult the troubleshooting guide for underlying credential types for more information.</li><ul><li>[EnvironmentCredential](#troubleshoot-environmentcredential-authentication-issues)</li><li>[WorkloadIdentityCredential](#troubleshoot-workloadidentitycredential-authentication-issues)</li><li>[ManagedIdentityCredential](#troubleshoot-managedidentitycredential-authentication-issues)</li><li>[VisualStudioCredential](#troubleshoot-visualstudiocredential-authentication-issues)</li><li>[AzureCliCredential](#troubleshoot-azureclicredential-authentication-issues)</li><li>[AzurePowerShellCredential](#troubleshoot-azurepowershellcredential-authentication-issues)</li></ul>|
127127
|`RequestFailedException` raised from the client with a status code of 401 or 403|Authentication succeeded but the authorizing Azure service responded with a 401 (Authenticate) or 403 (Forbidden) status code. This error can often be caused by the `DefaultAzureCredential` authenticating an account other than the intended or that the intended account doesn't have the correct permissions or roles assigned.|<ul><li>[Enable logging](#enable-and-configure-logging) to determine which credential in the chain returned the authenticating token.</li><li>In the case a credential other than the expected is returning a token, bypass this by either signing out of the corresponding development tool, or excluding the credential with the ExcludeXXXCredential property in the `DefaultAzureCredentialOptions`</li><li>Ensure that the correct role is assigned to the account being used. For example, a service specific role rather than the subscription Owner role.</li></ul>|
128-
|`InvalidOperationException` raised with message: "Invalid value for environment variable AZURE_TOKEN_CREDENTIALS ..." | An invalid value was set for the AZURE_TOKEN_CREDENTIALS environment variable | Set the environment variable to one of the following values: dev, prod, `VisualStudioCredential`, `VisualStudioCodeCredential`, `AzureCliCredential`, `AzurePowerShellCredential`, `AzureDeveloperCliCredential`, `EnvironmentCredential`, `WorkloadIdentityCredential`, `ManagedIdentityCredential`, `InteractiveBrowserCredential`, or `BrokerAuthenticationCredential`. **Note:** `BrokerAuthenticationCredential` require that the project include a reference to package Azure.Identity.Broker. |
128+
|`InvalidOperationException` raised with message: "Invalid value for environment variable AZURE_TOKEN_CREDENTIALS ..." | An invalid value was set for the AZURE_TOKEN_CREDENTIALS environment variable | Set the environment variable to one of the following values: dev, prod, `VisualStudioCredential`, `VisualStudioCodeCredential`, `AzureCliCredential`, `AzurePowerShellCredential`, `AzureDeveloperCliCredential`, `EnvironmentCredential`, `WorkloadIdentityCredential`, `ManagedIdentityCredential`, `InteractiveBrowserCredential`, or `BrokerCredential`. **Note:** `BrokerCredential` require that the project include a reference to package Azure.Identity.Broker. |
129129

130130
## Troubleshoot `EnvironmentCredential` authentication issues
131131

sdk/identity/Azure.Identity/src/Constants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ internal class Constants
5252
public const string WorkloadIdentityCredential = "workloadidentitycredential";
5353
public const string ManagedIdentityCredential = "managedidentitycredential";
5454
public const string InteractiveBrowserCredential = "interactivebrowsercredential";
55-
public const string BrokerAuthenticationCredential = "brokerauthenticationcredential";
55+
public const string BrokerCredential = "brokercredential";
5656
public const string MacBrokerRedirectUri = "msauth.com.msauth.unsignedapp://auth";
5757
}
5858
}

sdk/identity/Azure.Identity/src/DefaultAzureCredentialFactory.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public TokenCredential[] CreateCredentialChain()
5858
}
5959
else if (credentialSelection != null)
6060
{
61-
string validCredentials = $"'{Constants.DevCredentials}', '{Constants.ProdCredentials}', '{Constants.VisualStudioCredential}', '{Constants.VisualStudioCodeCredential}', '{Constants.AzureCliCredential}', '{Constants.AzurePowerShellCredential}', '{Constants.AzureDeveloperCliCredential}', '{Constants.EnvironmentCredential}', '{Constants.WorkloadIdentityCredential}', '{Constants.ManagedIdentityCredential}', '{Constants.InteractiveBrowserCredential}', '{Constants.BrokerAuthenticationCredential}'";
61+
string validCredentials = $"'{Constants.DevCredentials}', '{Constants.ProdCredentials}', '{Constants.VisualStudioCredential}', '{Constants.VisualStudioCodeCredential}', '{Constants.AzureCliCredential}', '{Constants.AzurePowerShellCredential}', '{Constants.AzureDeveloperCliCredential}', '{Constants.EnvironmentCredential}', '{Constants.WorkloadIdentityCredential}', '{Constants.ManagedIdentityCredential}', '{Constants.InteractiveBrowserCredential}', '{Constants.BrokerCredential}'";
6262
return credentialSelection switch
6363
{
6464
Constants.VisualStudioCredential => [CreateVisualStudioCredential()],
@@ -70,10 +70,10 @@ public TokenCredential[] CreateCredentialChain()
7070
Constants.WorkloadIdentityCredential => [CreateWorkloadIdentityCredential()],
7171
Constants.ManagedIdentityCredential => [CreateManagedIdentityCredential()],
7272
Constants.InteractiveBrowserCredential => [CreateInteractiveBrowserCredential()],
73-
Constants.BrokerAuthenticationCredential =>
73+
Constants.BrokerCredential =>
7474
TryCreateDevelopmentBrokerOptions(out InteractiveBrowserCredentialOptions brokerOptions)
75-
? [CreateBrokerAuthenticationCredential(brokerOptions)]
76-
: throw new CredentialUnavailableException("BrokerAuthenticationCredential is not available without a reference to Azure.Identity.Broker."),
75+
? [CreateBrokerCredential(brokerOptions)]
76+
: throw new CredentialUnavailableException("BrokerCredential is not available without a reference to Azure.Identity.Broker."),
7777
_ => throw new InvalidOperationException($"Invalid value for environment variable AZURE_TOKEN_CREDENTIALS: {credentialSelection}. Valid values are {validCredentials}. See https://aka.ms/azsdk/net/identity/defaultazurecredential/troubleshoot for more information.")
7878
};
7979
}
@@ -140,7 +140,7 @@ public TokenCredential[] CreateCredentialChain()
140140
}
141141
if (!Options.ExcludeBrokerCredential && TryCreateDevelopmentBrokerOptions(out InteractiveBrowserCredentialOptions brokerOptions))
142142
{
143-
chain.Add(CreateBrokerAuthenticationCredential(brokerOptions));
143+
chain.Add(CreateBrokerCredential(brokerOptions));
144144
}
145145
}
146146
if (chain.Count == 0)
@@ -238,7 +238,7 @@ public virtual TokenCredential CreateInteractiveBrowserCredential()
238238
Pipeline);
239239
}
240240

241-
public TokenCredential CreateBrokerAuthenticationCredential(InteractiveBrowserCredentialOptions brokerOptions)
241+
public TokenCredential CreateBrokerCredential(InteractiveBrowserCredentialOptions brokerOptions)
242242
{
243243
var options = Options.Clone<DevelopmentBrokerOptions>();
244244
((IMsalSettablePublicClientInitializerOptions)options).BeforeBuildClient = ((IMsalSettablePublicClientInitializerOptions)brokerOptions).BeforeBuildClient;

sdk/identity/Azure.Identity/tests/DefaultAzureCredentialFactoryTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ public static IEnumerable<object[]> CredSelection()
427427
yield return new object[] { Constants.WorkloadIdentityCredential };
428428
yield return new object[] { Constants.ManagedIdentityCredential };
429429
yield return new object[] { Constants.InteractiveBrowserCredential };
430-
yield return new object[] { Constants.BrokerAuthenticationCredential };
430+
yield return new object[] { Constants.BrokerCredential };
431431
yield return new object[] { null };
432432
}
433433

@@ -444,11 +444,11 @@ public void ValidateDefaultAzureCredentialAZURE_TOKEN_CREDENTIALS_Honored(string
444444
}))
445445
{
446446
var factory = new DefaultAzureCredentialFactory(null);
447-
if (credSelection == Constants.BrokerAuthenticationCredential)
447+
if (credSelection == Constants.BrokerCredential)
448448
{
449-
// BrokerAuthenticationCredential is not supported without the Azure.Identity.Broker package.
449+
// BrokerCredential is not supported without the Azure.Identity.Broker package.
450450
var ex = Assert.Throws<CredentialUnavailableException>(() => factory.CreateCredentialChain());
451-
Assert.AreEqual("BrokerAuthenticationCredential is not available without a reference to Azure.Identity.Broker.", ex.Message);
451+
Assert.AreEqual("BrokerCredential is not available without a reference to Azure.Identity.Broker.", ex.Message);
452452
return;
453453
}
454454
var chain = factory.CreateCredentialChain();

0 commit comments

Comments
 (0)