Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable broker support on Linux platform #5086

Open
wants to merge 98 commits into
base: main
Choose a base branch
from
Open

Conversation

xinyuxu1026
Copy link

@xinyuxu1026 xinyuxu1026 commented Jan 16, 2025

Fixes #

Changes proposed in this request

  • Add broker support on Linux and WSL platforms
    • Linux platform doesn't require a new one to be registered, it should be able to use the same redirect_uri as Windows platform.
    • For parent window, on Linux we import libX11 to get the window handle, and this applies to both Linux and WSL since they are both Linux environments
    • Linux broker doesn't support POP
  • Update msalruntime to version 0.18.0

Testing

  • Microsoft.Identity.Test.Integration.NetCore tests are enabled in the CI for Linux platform

Performance impact

Documentation

  • All relevant documentation is updated.

@xinyuxu1026 xinyuxu1026 requested a review from a team as a code owner January 16, 2025 00:05
NuGet.Config Outdated Show resolved Hide resolved
@@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you also add this project to the MSAL Runtime dll checks that happens in the build pipepline

@@ -586,7 +587,7 @@ public void HandleInstallUrl(string appLink)

public bool IsBrokerInstalledAndInvokable(AuthorityType authorityType)
{
if (!DesktopOsHelper.IsWin10OrServerEquivalent())
if (!DesktopOsHelper.IsWin10OrServerEquivalent() && !DesktopOsHelper.IsLinux())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you able to add some unit tests?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, we don't really have unit tests for these helpers and I'm not sure how useful they'd be.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, for this PR, I start from enabling the Microsoft.Identity.Test.Integration.NetCore tests in the CI for linux platform. Please take a look. the Unit tests rely on Microsoft.Identity.Client.Desktop which is Windows only

@gladjohn gladjohn requested a review from Copilot January 16, 2025 05:09

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 10 changed files in this pull request and generated no comments.

Files not reviewed (5)
  • Directory.Packages.props: Language not supported
  • NuGet.Config: Language not supported
  • src/client/Microsoft.Identity.Client.Broker/Microsoft.Identity.Client.Broker.csproj: Language not supported
  • tests/devapps/WAM/NetWSLWam/Properties/launchSettings.json: Language not supported
  • tests/devapps/WAM/NetWSLWam/test.csproj: Language not supported
Comments suppressed due to low confidence (2)

src/client/Microsoft.Identity.Client/PlatformsCommon/Shared/DesktopOsHelper.cs:59

  • [nitpick] The method name 'IsRunningOnWsl' could be more descriptive. Consider renaming it to 'IsRunningOnWindowsSubsystemForLinux'.
public static bool IsRunningOnWsl()

src/client/Microsoft.Identity.Client.Broker/RuntimeBroker.cs:129

  • Replace the debug log statement with a proper logging mechanism: _logger.Info("Runtime Broker AcquireTokenInteractiveAsync");
Console.WriteLine("Runtime Broker AcquireTokenInteractiveAsync");
@@ -79,6 +79,20 @@ private static void AddRuntimeSupport(PublicClientApplicationBuilder builder)
logger.Info("[Runtime] WAM supported OS.");
return new RuntimeBroker(uiParent, appConfig, logger);
};
} else if (DesktopOsHelper.IsRunningOnWsl()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you create a helper method so the dupe can be avoided?

/// <summary>
/// Use broker on WSL
/// </summary>
WSL = 0b_0000_0011, // 3
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason we made the OS an explicit API is to allow app developers to opt-in to different brokers, because different brokers have different:

  • redirect_uri
  • parent window details

Is the E2E setup on Linux different than the broker setup on WSL? If not, I would not complicate the dev experience with this option and I'd just add "Linux".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is, pls explain with a comment in the code, ideally pointing to an aka.ms doc

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with what @bgavrilMS said. To that end, I am curious to know what the scope of this PR is. Does it bring broker support for BOTH wsl and non-wsl, @xinyuxu1026 ?

For what it's worth, there is currently a similar PR for MSAL Python, but it targets wsl only; and I am told that the "wsl broker" is WAM so it has the redirect_uri requirement identical to WAM, and the "non-wsl broker" does not use that redirect_uri.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, this PR would support for both WSL and Standalone linux environments. For the redirect_uri, the Linux platform doesn't require a new one to be registered, it should be able to use the same redirect_uri as Windows platform. For the parent window, on Linux we import libX11 to get the window handle, and this applies to both Linux and WSL since they are both Linux environments. Therefore, I removed the WSL broker options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants