Skip to content

Commit a1caf5a

Browse files
JonathanCrdscottaddiechristothes
authored
[Identity] Deprecate SharedTokenCacheCredential and remove preview-flag checks for the Broker (Azure#51587)
* Remove PREVIEW_FEATURE_FLAG from Broker Credential * Remove unnecessary warning disable for obsolete type. VSCode credential is no longer obsolete. * Remove temporary constants since Mac Broker is now available on the latest Azure.Identity beta * Marked `DefaultAzureCredentialOptions.ExcludeSharedTokenCacheCredential`, `SharedTokenCacheCredential`, `SharedTokenCacheCredentialOptions`, and `SharedTokenCacheCredentialBrokerOptions` as obsolete * Updated changelogs * Disable obsolete warning for tests and clone method * Export API * Apply suggestions from code review Co-authored-by: Scott Addie <[email protected]> * Scope warning disable to lines of code instead of entire tests * Update sdk/identity/Azure.Identity/CHANGELOG.md Co-authored-by: Christopher Scott <[email protected]> --------- Co-authored-by: Scott Addie <[email protected]> Co-authored-by: Christopher Scott <[email protected]>
1 parent e3b8e61 commit a1caf5a

18 files changed

+58
-30
lines changed

sdk/identity/Azure.Identity.Broker/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
### Breaking Changes
88

9+
- Deprecated `SharedTokenCacheCredentialBrokerOptions`. The supporting credential (`SharedTokenCacheCredential`) was a legacy mechanism for authenticating clients using credentials provided to Visual Studio. For brokered authentication, consider using `InteractiveBrowserCredential` instead.
10+
911
### Bugs Fixed
1012

1113
### Other Changes

sdk/identity/Azure.Identity.Broker/api/Azure.Identity.Broker.net462.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ public InteractiveBrowserCredentialBrokerOptions(System.IntPtr parentWindowHandl
66
public bool? IsLegacyMsaPassthroughEnabled { get { throw null; } set { } }
77
public bool UseDefaultBrokerAccount { get { throw null; } set { } }
88
}
9+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
10+
[System.ObsoleteAttribute("SharedTokenCacheCredential is deprecated. For brokered authentication, consider using InteractiveBrowserCredential.")]
911
public partial class SharedTokenCacheCredentialBrokerOptions : Azure.Identity.SharedTokenCacheCredentialOptions
1012
{
1113
public SharedTokenCacheCredentialBrokerOptions() { }

sdk/identity/Azure.Identity.Broker/api/Azure.Identity.Broker.net8.0.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ public InteractiveBrowserCredentialBrokerOptions(System.IntPtr parentWindowHandl
66
public bool? IsLegacyMsaPassthroughEnabled { get { throw null; } set { } }
77
public bool UseDefaultBrokerAccount { get { throw null; } set { } }
88
}
9+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
10+
[System.ObsoleteAttribute("SharedTokenCacheCredential is deprecated. For brokered authentication, consider using InteractiveBrowserCredential.")]
911
public partial class SharedTokenCacheCredentialBrokerOptions : Azure.Identity.SharedTokenCacheCredentialOptions
1012
{
1113
public SharedTokenCacheCredentialBrokerOptions() { }

sdk/identity/Azure.Identity.Broker/api/Azure.Identity.Broker.netstandard2.0.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ public InteractiveBrowserCredentialBrokerOptions(System.IntPtr parentWindowHandl
66
public bool? IsLegacyMsaPassthroughEnabled { get { throw null; } set { } }
77
public bool UseDefaultBrokerAccount { get { throw null; } set { } }
88
}
9+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
10+
[System.ObsoleteAttribute("SharedTokenCacheCredential is deprecated. For brokered authentication, consider using InteractiveBrowserCredential.")]
911
public partial class SharedTokenCacheCredentialBrokerOptions : Azure.Identity.SharedTokenCacheCredentialOptions
1012
{
1113
public SharedTokenCacheCredentialBrokerOptions() { }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1414
</PropertyGroup>
1515
<ItemGroup>
16-
<PackageReference Include="Azure.Identity" VersionOverride="1.14.0-beta.4" />
16+
<PackageReference Include="Azure.Identity" VersionOverride="1.15.0-beta.1" />
1717
<PackageReference Include="Microsoft.Identity.Client.Broker" />
1818
</ItemGroup>
1919
</Project>

sdk/identity/Azure.Identity.Broker/src/DevelopmentBrokerOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public DevelopmentBrokerOptions() : base()
3636
// Set default value for UseDefaultBrokerAccount on macOS
3737
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
3838
{
39-
RedirectUri = new(TemporaryConstants.MacBrokerRedirectUri);
39+
RedirectUri = new(Constants.MacBrokerRedirectUri);
4040
}
4141
}
4242

sdk/identity/Azure.Identity.Broker/src/InteractiveBrowserCredentialBrokerOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public InteractiveBrowserCredentialBrokerOptions(IntPtr parentWindowHandle) : ba
3737
// Set default value for UseDefaultBrokerAccount on macOS
3838
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
3939
{
40-
RedirectUri = new(TemporaryConstants.MacBrokerRedirectUri);
40+
RedirectUri = new(Constants.MacBrokerRedirectUri);
4141
}
4242
}
4343

sdk/identity/Azure.Identity.Broker/src/SharedTokenCacheCredentialBrokerOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
using System;
5+
using System.ComponentModel;
56
using Microsoft.Identity.Client;
67
using Microsoft.Identity.Client.Broker;
78

@@ -10,6 +11,8 @@ namespace Azure.Identity.Broker
1011
/// <summary>
1112
/// Options to configure the <see cref="SharedTokenCacheCredential"/> to use the system authentication broker for silent authentication if available.
1213
/// </summary>
14+
[Obsolete("SharedTokenCacheCredential is deprecated. For brokered authentication, consider using InteractiveBrowserCredential.")]
15+
[EditorBrowsable(EditorBrowsableState.Never)]
1316
public class SharedTokenCacheCredentialBrokerOptions : SharedTokenCacheCredentialOptions, IMsalPublicClientInitializerOptions
1417
{
1518
/// <summary>

sdk/identity/Azure.Identity.Broker/src/TemporaryConstants.cs

Lines changed: 0 additions & 17 deletions
This file was deleted.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ public async Task SilentAuthenticateWithBrokerAsync()
3030
AccessToken token = await cred.GetTokenAsync(new TokenRequestContext(new string[] { "https://vault.azure.net/.default" })).ConfigureAwait(false);
3131

3232
Assert.NotNull(token.Token);
33-
33+
#pragma warning disable CS0618 // Type or member is obsolete
3434
var silentCred = new SharedTokenCacheCredential(new SharedTokenCacheCredentialBrokerOptions());
35+
#pragma warning restore CS0618 // Type or member is obsolete
3536

3637
// The calls below this should be silent and not require user interaction
3738
token = await cred.GetTokenAsync(new TokenRequestContext(new string[] { "https://vault.azure.net/.default" })).ConfigureAwait(false);
@@ -47,7 +48,9 @@ public async Task SilentAuthenticateWithBrokerAsync()
4748
[Ignore("This test is an integration test which can only be run with user interaction")]
4849
public async Task AuthenticateWithBrokerWithUseOperatingSystemAccount_DoesNotPrompt()
4950
{
51+
#pragma warning disable CS0618 // Type or member is obsolete
5052
var cred = new SharedTokenCacheCredential(new SharedTokenCacheCredentialBrokerOptions() { UseDefaultBrokerAccount = true });
53+
#pragma warning restore CS0618 // Type or member is obsolete
5154

5255
AccessToken token = await cred.GetTokenAsync(new TokenRequestContext(new string[] { "https://vault.azure.net/.default" })).ConfigureAwait(false);
5356

0 commit comments

Comments
 (0)