-
Notifications
You must be signed in to change notification settings - Fork 347
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
base: main
Are you sure you want to change the base?
Conversation
NuGet.Config
Outdated
@@ -3,5 +3,6 @@ | |||
<packageSources> | |||
<clear /> | |||
<add key="NuGet" value="https://api.nuget.org/v3/index.json" /> | |||
<add key="LocalPackages" value="/mnt/c/Users//Documents/MyLocalNugetPackages" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove this
Directory.Packages.props
Outdated
@@ -2,7 +2,7 @@ | |||
<PropertyGroup> | |||
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally> | |||
<!-- Version of the Microsoft.Identity.Client.NativeInterop package. --> | |||
<MSALRuntimeNativeInteropVersion>0.16.2</MSALRuntimeNativeInteropVersion> | |||
<MSALRuntimeNativeInteropVersion>0.18.0</MSALRuntimeNativeInteropVersion> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is 0.18.0 published, I don't see it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We haven't published it yet due to the potential breaking change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please publish a -preview version or a version lower than the one that is current and test this on priority @xinyuxu1026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@xinyuxu1026 , can you elaborate on what the potential breaking change might be?
@DharshanBJ , will that affect the already-shipped PyMsalRuntime 0.18.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This breaking change is about the dll redistribution of nuget package on dotnet (ref: #5019), it should not affect the python package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is it a breaking change @xinyuxu1026 ? The public API doesn't change. Is it behavioral? Do applications need to do extra work on their own to package the native binaries?
We really should try to avoid breaking changes. All these packages have been released in-sync (same version) with MSAL. It's simple and effective.
@@ -4,7 +4,7 @@ | |||
<TargetFrameworkNetStandard>netstandard2.0</TargetFrameworkNetStandard> | |||
<TargetFrameworkNetDesktop Condition="$([MSBuild]::IsOsPlatform('Windows'))">net462</TargetFrameworkNetDesktop> | |||
<PlatformTarget>AnyCPU</PlatformTarget> | |||
<TargetFramework Condition="'$(TargetFrameworkNetDesktop)' == ''">$(TargetFrameworkNetStandard)</TargetFramework> | |||
<TargetFramework Condition="'$(TargetFrameworkNetDesktop) == ''">$(TargetFrameworkNetStandard)</TargetFramework> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
undo
@@ -126,6 +126,7 @@ public async Task<MsalTokenResponse> AcquireTokenInteractiveAsync( | |||
AuthenticationRequestParameters authenticationRequestParameters, | |||
AcquireTokenInteractiveParameters acquireTokenInteractiveParameters) | |||
{ | |||
Console.WriteLine("Runtime Broker AcquireTokenInteractiveAsync"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
@@ -0,0 +1,19 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()) { |
There was a problem hiding this comment.
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?
public static bool IsRunningOnWsl() | ||
{ | ||
if (IsLinux()) { | ||
var versionInfo = File.ReadAllText("/proc/version"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be fairly expensive operation. Use the lazy trick to cache the result ? See line 20.
/// <summary> | ||
/// Use broker on WSL | ||
/// </summary> | ||
WSL = 0b_0000_0011, // 3 |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
@@ -81,6 +85,8 @@ internal bool IsBrokerEnabledOnCurrentOs() | |||
if (EnabledOn.HasFlag(OperatingSystems.Windows) && DesktopOsHelper.IsWindows()) | |||
{ | |||
return true; | |||
} else if (DesktopOsHelper.IsLinux()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to check if EnabledOn.HasFlag(OperatingSystems.Linux)
?
Fixes #
Changes proposed in this request
Testing
Performance impact
Documentation