Skip to content

Commit 01ff6bb

Browse files
authored
[Identity] Exclude SharedTokenCacheCredential from DefaultAzureCredential by default (Azure#16615)
* [Identity] Exclude SharedTokenCacheCredential from DefaultAzureCredential by default * adding BREAKING_CHANGES.md * link changelog to breaking_changes
1 parent 1126f0b commit 01ff6bb

File tree

5 files changed

+47
-11
lines changed

5 files changed

+47
-11
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Breaking Changes
2+
3+
## 1.4.0
4+
5+
### Changed `ExcludeSharedTokenCacheCredential` default value from __false__ to __true__ on `DefaultAzureCredentialsOptions`
6+
7+
Starting in Azure.Identity 1.4.0-beta.4 the default value of the `ExcludeSharedTokenCacheCredential` property on `DefaultAzureCredentialsOptions` has changed from __false__ to __true__, excluding the `SharedTokenCacheCredential` from the `DefaultAzureCredential` authentication flow by default. We expect that few users will be impacted by this change as the `VisualStudioCredential` has effectively replaced the `SharedTokenCacheCredential` in this authentication flow. However, users who find this change does negatively impact them can still invoke the old behavior by explicitly setting the value to false.
8+
9+
```C# Snippet:Identity_BreakingChanges_SetExcludeSharedTokenCacheCredentialToFalse
10+
var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions
11+
{
12+
ExcludeSharedTokenCacheCredential = false
13+
});
14+
```
15+
16+
More information on this change and the consideration behind it can be found [here](https://github.com/Azure/azure-sdk/issues/1970).

sdk/identity/Azure.Identity/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
## 1.4.0-beta.4 (Unreleased)
44

5+
### Breaking Changes
6+
7+
- Update the default value of `ExcludeSharedTokenCacheCredential` on `DefaultAzureCredentialsOptions` to true, to exclude the `SharedTokenCacheCredential` from the `DefaultAzureCredential` by default. See [BREAKING_CHANGES.md](https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/identity/Azure.Identity/BREAKING_CHANGES.md#140)
58

69
## 1.4.0-beta.3 (2021-02-09)
710

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public class DefaultAzureCredentialOptions : TokenCredentialOptions
7272
/// Specifies whether the <see cref="SharedTokenCacheCredential"/> will be excluded from the <see cref="DefaultAzureCredential"/> authentication flow.
7373
/// Setting to true disables single sign on authentication with development tools which write to the shared token cache.
7474
/// </summary>
75-
public bool ExcludeSharedTokenCacheCredential { get; set; }
75+
public bool ExcludeSharedTokenCacheCredential { get; set; } = true;
7676

7777
/// <summary>
7878
/// Specifies whether the <see cref="InteractiveBrowserCredential"/> will be excluded from the <see cref="DefaultAzureCredential"/> authentication flow.

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

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@ public void ValidateCtorNoOptions()
3030
Assert.AreEqual(sources.Length, 7);
3131
Assert.IsInstanceOf(typeof(EnvironmentCredential), sources[0]);
3232
Assert.IsInstanceOf(typeof(ManagedIdentityCredential), sources[1]);
33-
Assert.IsInstanceOf(typeof(SharedTokenCacheCredential), sources[2]);
34-
Assert.IsInstanceOf(typeof(VisualStudioCredential), sources[3]);
35-
Assert.IsInstanceOf(typeof(VisualStudioCodeCredential), sources[4]);
36-
Assert.IsInstanceOf(typeof(AzureCliCredential), sources[5]);
33+
Assert.IsInstanceOf(typeof(VisualStudioCredential), sources[2]);
34+
Assert.IsInstanceOf(typeof(VisualStudioCodeCredential), sources[3]);
35+
Assert.IsInstanceOf(typeof(AzureCliCredential), sources[4]);
3736
Assert.IsNull(sources[6]);
3837
}
3938

@@ -48,18 +47,17 @@ public void ValidateCtorIncludedInteractiveParam([Values(true, false)] bool incl
4847
Assert.AreEqual(sources.Length, 7);
4948
Assert.IsInstanceOf(typeof(EnvironmentCredential), sources[0]);
5049
Assert.IsInstanceOf(typeof(ManagedIdentityCredential), sources[1]);
51-
Assert.IsInstanceOf(typeof(SharedTokenCacheCredential), sources[2]);
52-
Assert.IsInstanceOf(typeof(VisualStudioCredential), sources[3]);
53-
Assert.IsInstanceOf(typeof(VisualStudioCodeCredential), sources[4]);
54-
Assert.IsInstanceOf(typeof(AzureCliCredential), sources[5]);
50+
Assert.IsInstanceOf(typeof(VisualStudioCredential), sources[2]);
51+
Assert.IsInstanceOf(typeof(VisualStudioCodeCredential), sources[3]);
52+
Assert.IsInstanceOf(typeof(AzureCliCredential), sources[4]);
5553

5654
if (includeInteractive)
5755
{
58-
Assert.IsInstanceOf(typeof(InteractiveBrowserCredential), sources[6]);
56+
Assert.IsInstanceOf(typeof(InteractiveBrowserCredential), sources[5]);
5957
}
6058
else
6159
{
62-
Assert.IsNull(sources[6]);
60+
Assert.IsNull(sources[5]);
6361
}
6462
}
6563

@@ -91,6 +89,7 @@ public void ValidateCtorOptionsPassedToCredentials()
9189
{
9290
ManagedIdentityClientId = expClientId,
9391
SharedTokenCacheUsername = expUsername,
92+
ExcludeSharedTokenCacheCredential = false,
9493
SharedTokenCacheTenantId = expCacheTenantId,
9594
VisualStudioTenantId = expVsTenantId,
9695
VisualStudioCodeTenantId = expCodeTenantId,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
namespace Azure.Identity.Tests.samples
5+
{
6+
public class BreakingChangesSnippets
7+
{
8+
public void SetExcludeSharedTokenCacheCredentialToFalse()
9+
{
10+
#region Snippet:Identity_BreakingChanges_SetExcludeSharedTokenCacheCredentialToFalse
11+
var credential = new DefaultAzureCredential(new DefaultAzureCredentialOptions
12+
{
13+
ExcludeSharedTokenCacheCredential = false
14+
});
15+
#endregion
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)