Skip to content

Commit eca8faf

Browse files
authored
Update Azure.Identity.BrokeredAuthentication dependency to Microsoft.Identity.Client.Broker (Azure#30406)
* updating to use native broker impl * upgrade to latest msal * disabling manual test * re-record live tests * revert local testing Nuget.Config changes * update api spec * remove net462 ref from brokered auth tests * adding comment to beta package dependency * fix targetframeworks for mac and linux * fix ACS test class for MSAL break * making MSAL reference explicit * updating snippets * exclude broker tests on non-windows
1 parent b93219c commit eca8faf

File tree

62 files changed

+1770
-1627
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1770
-1627
lines changed

eng/Packages.Data.props

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,13 @@
104104
<!-- Other approved packages -->
105105
<PackageReference Update="Microsoft.Azure.Amqp" Version="2.5.10" />
106106
<PackageReference Update="Microsoft.Azure.WebPubSub.Common" Version="1.1.0" />
107-
<PackageReference Update="Microsoft.Identity.Client" Version="4.39.0" />
108-
<PackageReference Update="Microsoft.Identity.Client.Desktop" Version="4.39.0" />
109-
<PackageReference Update="Microsoft.Identity.Client.Extensions.Msal" Version="2.19.3" />
107+
<PackageReference Update="Microsoft.Identity.Client" Version="4.46.0" />
108+
<PackageReference Update="Microsoft.Identity.Client.Extensions.Msal" Version="2.23.0" />
109+
<!--
110+
TODO: This package needs to be released as GA and arch-board approved before taking a dependency in any stable SDK library.
111+
Currently, it is referencd by Azure.Identity.BrokeredAuthentication which is still in beta
112+
-->
113+
<PackageReference Update="Microsoft.Identity.Client.Broker" Version="4.46.0-preview" />
110114

111115
<!-- TODO: Make sure this package is arch-board approved -->
112116
<PackageReference Update="System.IdentityModel.Tokens.Jwt" Version="6.5.0" />

sdk/communication/Azure.Communication.Identity/tests/Azure.Communication.Identity.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<PackageReference Include="NUnit" />
99
<PackageReference Include="NUnit3TestAdapter" />
1010
<PackageReference Include="Microsoft.NET.Test.Sdk" />
11+
<PackageReference Include="Microsoft.Identity.Client" />
1112
</ItemGroup>
1213
<ItemGroup>
1314
<ProjectReference Include="$(AzureCoreTestFramework)" />

sdk/communication/Azure.Communication.Identity/tests/Infrastructure/CommunicationIdentityClientLiveTestBase.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,11 @@ protected async Task<GetTokenForTeamsUserOptions> CreateTeamsUserParams()
7272
"https://auth.msft.communication.azure.com/Teams.ManageCalls",
7373
"https://auth.msft.communication.azure.com/Teams.ManageChats"
7474
};
75-
SecureString communicationMsalPassword = new SecureString();
76-
foreach (char c in TestEnvironment.CommunicationMsalPassword)
77-
{
78-
communicationMsalPassword.AppendChar(c);
79-
}
75+
8076
AuthenticationResult result = await publicClientApplication.AcquireTokenByUsernamePassword(
8177
scopes,
8278
TestEnvironment.CommunicationMsalUsername,
83-
communicationMsalPassword).ExecuteAsync(CancellationToken.None).ConfigureAwait(false);
79+
TestEnvironment.CommunicationMsalPassword).ExecuteAsync(CancellationToken.None).ConfigureAwait(false);
8480
options = new GetTokenForTeamsUserOptions(result.AccessToken, TestEnvironment.CommunicationM365AppId, result.UniqueId);
8581
}
8682
return options;

sdk/identity/Azure.Identity.BrokeredAuthentication/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ dotnet add package Azure.Identity.BrokeredAuthentication --prerelease
2727
This example demonstrates configuring the `InteractiveBrowserCredential` with the specialized options type `InteractiveBrowserCredentialBrokerOptions` to enable brokered authentication.
2828

2929
```C# Snippet:ConfigureInteractiveBrowserToUseBroker
30+
IntPtr parentWindowHandle = GetForegroundWindow();
31+
3032
// Create an interactive browser credential which will use the system authentication broker
31-
var credential = new InteractiveBrowserCredential(new InteractiveBrowserCredentialBrokerOptions());
33+
var credential = new InteractiveBrowserCredential(new InteractiveBrowserCredentialBrokerOptions(parentWindowHandle));
3234

3335
// Use the credential to authenticate a secret client
3436
var client = new SecretClient(new Uri("https://myvault.vault.azure.net/"), credential);
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Azure.Identity.BrokeredAuthentication
2+
{
3+
public partial class InteractiveBrowserCredentialBrokerOptions : Azure.Identity.InteractiveBrowserCredentialOptions
4+
{
5+
public InteractiveBrowserCredentialBrokerOptions(System.IntPtr parentWindowHandle) { }
6+
}
7+
public partial class SharedTokenCacheCredentialBrokerOptions : Azure.Identity.SharedTokenCacheCredentialOptions
8+
{
9+
public SharedTokenCacheCredentialBrokerOptions() { }
10+
public SharedTokenCacheCredentialBrokerOptions(Azure.Identity.TokenCachePersistenceOptions tokenCacheOptions) { }
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
namespace Azure.Identity.BrokeredAuthentication
2+
{
3+
public partial class InteractiveBrowserCredentialBrokerOptions : Azure.Identity.InteractiveBrowserCredentialOptions
4+
{
5+
public InteractiveBrowserCredentialBrokerOptions(System.IntPtr parentWindowHandle) { }
6+
}
7+
public partial class SharedTokenCacheCredentialBrokerOptions : Azure.Identity.SharedTokenCacheCredentialOptions
8+
{
9+
public SharedTokenCacheCredentialBrokerOptions() { }
10+
public SharedTokenCacheCredentialBrokerOptions(Azure.Identity.TokenCachePersistenceOptions tokenCacheOptions) { }
11+
}
12+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace Azure.Identity.BrokeredAuthentication
22
{
33
public partial class InteractiveBrowserCredentialBrokerOptions : Azure.Identity.InteractiveBrowserCredentialOptions
44
{
5-
public InteractiveBrowserCredentialBrokerOptions() { }
5+
public InteractiveBrowserCredentialBrokerOptions(System.IntPtr parentWindowHandle) { }
66
}
77
public partial class SharedTokenCacheCredentialBrokerOptions : Azure.Identity.SharedTokenCacheCredentialOptions
88
{

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
<AssemblyTitle>Microsoft Azure.Identity.BrokeredAuthentication Component</AssemblyTitle>
55
<Version>1.0.0-beta.3</Version>
66
<PackageTags>Microsoft Azure Identity Broker;$(PackageCommonTags)</PackageTags>
7-
<TargetFrameworks>$(RequiredTargetFrameworks);net461</TargetFrameworks>
7+
<TargetFrameworks Condition="$([MSBuild]::IsOsPlatform('Windows'))">$(RequiredTargetFrameworks);net462;netcoreapp3.1</TargetFrameworks>
8+
<TargetFrameworks Condition="$([MSBuild]::IsOsPlatform('OSX'))">$(RequiredTargetFrameworks);netcoreapp3.1</TargetFrameworks>
9+
<TargetFrameworks Condition="$([MSBuild]::IsOsPlatform('Linux')) ">$(RequiredTargetFrameworks);netcoreapp3.1</TargetFrameworks>
810
<NoWarn>$(NoWarn);3021</NoWarn>
911
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1012
</PropertyGroup>
@@ -17,9 +19,6 @@
1719
<PackageReference Include="Microsoft.Identity.Client" />
1820
<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" />
1921
<PackageReference Include="System.Security.Cryptography.ProtectedData" />
20-
</ItemGroup>
21-
<!--Only Add Microsoft.Identity.Client.Desktop when compiled for desktop-->
22-
<ItemGroup Condition="('$(TargetFramework)' == 'net461')">
23-
<PackageReference Include="Microsoft.Identity.Client.Desktop" />
22+
<PackageReference Include="Microsoft.Identity.Client.Broker" />
2423
</ItemGroup>
2524
</Project>

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
using System;
55
using Microsoft.Identity.Client;
6-
#if (NETFRAMEWORK)
7-
using Microsoft.Identity.Client.Desktop;
8-
#endif
6+
using Microsoft.Identity.Client.Broker;
97

108
namespace Azure.Identity.BrokeredAuthentication
119
{
@@ -14,15 +12,22 @@ namespace Azure.Identity.BrokeredAuthentication
1412
/// </summary>
1513
public class InteractiveBrowserCredentialBrokerOptions : InteractiveBrowserCredentialOptions, IMsalPublicClientInitializerOptions
1614
{
15+
private IntPtr _parentWindowHandle;
16+
17+
/// <summary>
18+
/// Creates a new instance of <see cref="InteractiveBrowserCredentialBrokerOptions"/> to configure a <see cref="InteractiveBrowserCredential"/>.
19+
/// </summary>
20+
/// <param name="parentWindowHandle">Handle of the parent window the system authentication broker should be docked to.</param>
21+
public InteractiveBrowserCredentialBrokerOptions(IntPtr parentWindowHandle) : base()
22+
{
23+
_parentWindowHandle = parentWindowHandle;
24+
}
25+
1726
Action<PublicClientApplicationBuilder> IMsalPublicClientInitializerOptions.BeforeBuildClient => AddBroker;
1827

1928
private void AddBroker(PublicClientApplicationBuilder builder)
2029
{
21-
#if (NETFRAMEWORK)
22-
builder.WithWindowsBroker();
23-
#else
24-
builder.WithBroker();
25-
#endif
30+
builder.WithBrokerPreview().WithParentActivityOrWindow(() => _parentWindowHandle);
2631
}
2732
}
2833
}

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33

44
using System;
55
using Microsoft.Identity.Client;
6-
#if (NETFRAMEWORK)
7-
using Microsoft.Identity.Client.Desktop;
8-
#endif
6+
using Microsoft.Identity.Client.Broker;
97

108
namespace Azure.Identity.BrokeredAuthentication
119
{
@@ -34,11 +32,7 @@ public SharedTokenCacheCredentialBrokerOptions(TokenCachePersistenceOptions toke
3432

3533
private void AddBroker(PublicClientApplicationBuilder builder)
3634
{
37-
#if (NETFRAMEWORK)
38-
builder.WithWindowsBroker();
39-
#else
40-
builder.WithBroker();
41-
#endif
35+
builder.WithBrokerPreview();
4236
}
4337
}
4438
}

0 commit comments

Comments
 (0)