Skip to content

Commit 910fc04

Browse files
authored
WAM silent SSO using the signed in windows account (#39607)
1 parent b3457ac commit 910fc04

15 files changed

+94
-9
lines changed

eng/Packages.Data.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
<PackageReference Update="Azure.Communication.Common" Version="1.2.1" />
110110
<PackageReference Update="Azure.Core" Version="1.37.0" />
111111
<PackageReference Update="Azure.Core.Amqp" Version="1.3.0" />
112-
<PackageReference Update="Azure.Core.Experimental" Version="0.1.0-preview.31" />
112+
<PackageReference Update="Azure.Core.Experimental" Version="0.1.0-preview.32" />
113113
<PackageReference Update="Azure.Core.Expressions.DataFactory" Version="1.0.0-beta.6" />
114114
<PackageReference Update="Azure.Data.SchemaRegistry" Version="1.2.0" />
115115
<PackageReference Update="Azure.Data.Tables" Version="12.8.0" />

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Features Added
66

7+
- `InteractiveBrowserCredentialBrokerOptions` and `SharedTokenCacheCredentialBrokerOptions` now support a `UseOperatingSystemAccount` property to enable the use of the currently logged in operating system account for authentication rather than prompting for a credential.
78
- Preview support for Proof of Possession (PoP) tokens for `InteractiveBrowserCredential`. This feature is enabled via the `IsProofOfPossessionRequired` property on `InteractiveBrowserCredentialBrokerOptions`.
89

910
### Breaking 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
@@ -5,12 +5,14 @@ public partial class InteractiveBrowserCredentialBrokerOptions : Azure.Identity.
55
public InteractiveBrowserCredentialBrokerOptions(System.IntPtr parentWindowHandle) { }
66
public bool? IsLegacyMsaPassthroughEnabled { get { throw null; } set { } }
77
public bool IsProofOfPossessionRequired { get { throw null; } set { } }
8+
public bool UseOperatingSystemAccount { get { throw null; } set { } }
89
}
910
public partial class SharedTokenCacheCredentialBrokerOptions : Azure.Identity.SharedTokenCacheCredentialOptions
1011
{
1112
public SharedTokenCacheCredentialBrokerOptions() { }
1213
public SharedTokenCacheCredentialBrokerOptions(Azure.Identity.TokenCachePersistenceOptions tokenCacheOptions) { }
1314
public bool? IsLegacyMsaPassthroughEnabled { get { throw null; } set { } }
1415
public bool IsProofOfPossessionRequired { get { throw null; } set { } }
16+
public bool UseOperatingSystemAccount { get { throw null; } set { } }
1517
}
1618
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@ public partial class InteractiveBrowserCredentialBrokerOptions : Azure.Identity.
55
public InteractiveBrowserCredentialBrokerOptions(System.IntPtr parentWindowHandle) { }
66
public bool? IsLegacyMsaPassthroughEnabled { get { throw null; } set { } }
77
public bool IsProofOfPossessionRequired { get { throw null; } set { } }
8+
public bool UseOperatingSystemAccount { get { throw null; } set { } }
89
}
910
public partial class SharedTokenCacheCredentialBrokerOptions : Azure.Identity.SharedTokenCacheCredentialOptions
1011
{
1112
public SharedTokenCacheCredentialBrokerOptions() { }
1213
public SharedTokenCacheCredentialBrokerOptions(Azure.Identity.TokenCachePersistenceOptions tokenCacheOptions) { }
1314
public bool? IsLegacyMsaPassthroughEnabled { get { throw null; } set { } }
1415
public bool IsProofOfPossessionRequired { get { throw null; } set { } }
16+
public bool UseOperatingSystemAccount { get { throw null; } set { } }
1517
}
1618
}

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
@@ -5,12 +5,14 @@ public partial class InteractiveBrowserCredentialBrokerOptions : Azure.Identity.
55
public InteractiveBrowserCredentialBrokerOptions(System.IntPtr parentWindowHandle) { }
66
public bool? IsLegacyMsaPassthroughEnabled { get { throw null; } set { } }
77
public bool IsProofOfPossessionRequired { get { throw null; } set { } }
8+
public bool UseOperatingSystemAccount { get { throw null; } set { } }
89
}
910
public partial class SharedTokenCacheCredentialBrokerOptions : Azure.Identity.SharedTokenCacheCredentialOptions
1011
{
1112
public SharedTokenCacheCredentialBrokerOptions() { }
1213
public SharedTokenCacheCredentialBrokerOptions(Azure.Identity.TokenCachePersistenceOptions tokenCacheOptions) { }
1314
public bool? IsLegacyMsaPassthroughEnabled { get { throw null; } set { } }
1415
public bool IsProofOfPossessionRequired { get { throw null; } set { } }
16+
public bool UseOperatingSystemAccount { get { throw null; } set { } }
1517
}
1618
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ public class InteractiveBrowserCredentialBrokerOptions : InteractiveBrowserCrede
2525
/// </summary>
2626
public bool IsProofOfPossessionRequired { get; set; }
2727

28+
/// <summary>
29+
/// Gets or sets whether to authenticate with the currently signed in user instead of prompting the user with a login dialog.
30+
/// </summary>
31+
public bool UseOperatingSystemAccount { get; set; }
32+
2833
/// <summary>
2934
/// Creates a new instance of <see cref="InteractiveBrowserCredentialBrokerOptions"/> to configure a <see cref="InteractiveBrowserCredential"/>.
3035
/// </summary>

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public class SharedTokenCacheCredentialBrokerOptions : SharedTokenCacheCredentia
2323
/// </summary>
2424
public bool IsProofOfPossessionRequired { get; set; }
2525

26+
/// <summary>
27+
/// Gets or sets whether to authenticate with the currently signed in user instead of prompting the user with a login dialog.
28+
/// </summary>
29+
public bool UseOperatingSystemAccount { get; set; }
30+
2631
/// <summary>
2732
/// Initializes a new instance of <see cref="SharedTokenCacheCredentialBrokerOptions"/>.
2833
/// </summary>

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ public void RespectsMsaPassthrough(
1818
IMsalPublicClientInitializerOptions credentialOptions;
1919
if (enableMsaPassthrough.HasValue)
2020
{
21-
credentialOptions = new InteractiveBrowserCredentialBrokerOptions(parentWindowHandle) { IsLegacyMsaPassthroughEnabled = enableMsaPassthrough.Value } as IMsalPublicClientInitializerOptions;
21+
credentialOptions = new InteractiveBrowserCredentialBrokerOptions(parentWindowHandle) { IsLegacyMsaPassthroughEnabled = enableMsaPassthrough.Value };
2222
}
2323
else
2424
{
25-
credentialOptions = new InteractiveBrowserCredentialBrokerOptions(parentWindowHandle) as IMsalPublicClientInitializerOptions;
25+
credentialOptions = new InteractiveBrowserCredentialBrokerOptions(parentWindowHandle);
2626
}
2727
PublicClientApplicationBuilder builder = PublicClientApplicationBuilder
2828
.Create(Guid.NewGuid().ToString());
@@ -34,6 +34,20 @@ public void RespectsMsaPassthrough(
3434
Assert.AreEqual(parentWindowHandle, Parent());
3535
}
3636

37+
[Test]
38+
public void RespectsUseOperatingSystemAccount(
39+
[Values(true, false)] bool enableUseOperatingSystemAccount)
40+
{
41+
IntPtr parentWindowHandle = new(1234);
42+
IMsalPublicClientInitializerOptions credentialOptions;
43+
credentialOptions = new InteractiveBrowserCredentialBrokerOptions(parentWindowHandle) { UseOperatingSystemAccount = enableUseOperatingSystemAccount };
44+
PublicClientApplicationBuilder builder = PublicClientApplicationBuilder
45+
.Create(Guid.NewGuid().ToString());
46+
47+
var credential = new InteractiveBrowserCredential((InteractiveBrowserCredentialBrokerOptions)credentialOptions);
48+
Assert.AreEqual(enableUseOperatingSystemAccount, credential.UseOperatingSystemAccount);
49+
}
50+
3751
private static (BrokerOptions Options, Func<object> Parent) GetBrokerOptions(PublicClientApplicationBuilder builder)
3852
{
3953
var config = builder

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@ public async Task AuthenticateWithBrokerAsync()
3434
Assert.NotNull(token.Token);
3535
}
3636

37+
[Test]
38+
[Ignore("This test is an integration test which can only be run with user interaction")]
39+
public async Task AuthenticateWithBrokerWithUseOperatingSystemAccount_DoesNotPrompt()
40+
{
41+
IntPtr parentWindowHandle = GetForegroundWindow();
42+
43+
var cred = new InteractiveBrowserCredential(new InteractiveBrowserCredentialBrokerOptions(parentWindowHandle) { UseOperatingSystemAccount = true });
44+
45+
AccessToken token = await cred.GetTokenAsync(new TokenRequestContext(new string[] { "https://vault.azure.net/.default" })).ConfigureAwait(false);
46+
47+
Assert.NotNull(token.Token);
48+
}
49+
3750
[Test]
3851
[TestCase(true)]
3952
[TestCase(false)]

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,16 @@ public async Task SilentAuthenticateWithBrokerAsync()
4242

4343
Assert.NotNull(token.Token);
4444
}
45+
46+
[Test]
47+
[Ignore("This test is an integration test which can only be run with user interaction")]
48+
public async Task AuthenticateWithBrokerWithUseOperatingSystemAccount_DoesNotPrompt()
49+
{
50+
var cred = new SharedTokenCacheCredential(new SharedTokenCacheCredentialBrokerOptions() { UseOperatingSystemAccount = true });
51+
52+
AccessToken token = await cred.GetTokenAsync(new TokenRequestContext(new string[] { "https://vault.azure.net/.default" })).ConfigureAwait(false);
53+
54+
Assert.NotNull(token.Token);
55+
}
4556
}
4657
}

0 commit comments

Comments
 (0)