Skip to content

Conversation

@mjcheetham
Copy link
Contributor

Use the new Windows broker which is based on the MSALRuntime; an export wrapper around a native, cross-platform MSAL library.

In this new set up, we drop the .Desktop package in favour of the .Broker package that also means we drop the WebView2Loader.dll, which we didn't make use of anyway. There are a few new binaries to be distributed in the new model, including a P/Invoke layer, IdentityModel abstractions library, and the native msalruntime_x86.dll.

Note that GCM still only support x86 on Windows, and only supports broker use on Windows. For this reason we don't bother adding the broker package on non-.NET Framework builds to keep the sizes on Mac/Linux to a minimum.

Also update the MSAL extensions library whilst we are here to pick up various bug fixes, and drop workarounds that are no longer required for this new broker implementation!

@mjcheetham mjcheetham added auth:microsoft Specific to Microsoft AAD/MSA authentication windows-broker Related to the Windows "Web Account Manager" authentication broker labels Apr 7, 2023
@mjcheetham mjcheetham requested a review from ldennington April 7, 2023 20:43
Use the new Windows broker which is based on the MSALRuntime; an export
wrapper around a native, cross-platform MSAL library.

In this new set up, we drop the `.Desktop` package in favour of the
`.Broker` package that also means we drop the WebView2Loader.dll, which
we didn't make use of anyway. There are a few new binaries to be
distrubuted in the new model, including a P/Invoke layer, IdentityModel
abstractions library, and the native msalruntime_x86.dll.

Note that GCM still only support x86 on Windows, and only supports
broker use on Windows. For this reason we don't bother adding the broker
package on non-.NET Framework builds to keep the sizes on Mac/Linux to a
minimium.
Always set the parent window handle for MSAL on Windows.

Previously we only set this if provided a handle by the user/config. Now
however we must always try and provide a handle because using the new
MSALRuntime-based Windows broker means we must do so - MSAL no longer
provides us with a 'dummy' handle to use.

Use the parent console window handle, as recommended by the MSAL docs:
https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/wam#parent-window-handles
@mjcheetham
Copy link
Contributor Author

@bgavrilMS could a member of the MSAL team have a quick glance over our usage of the new broker implementation on Windows, to make sure we're not doing something wrong? Thanks!

Copy link
Contributor

@ldennington ldennington left a comment

Choose a reason for hiding this comment

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

Looks great! This allowed for a lot of nice cleanup.

@mjcheetham mjcheetham force-pushed the msal-broker-v2 branch 2 times, most recently from 3f1b017 to cffba7a Compare April 11, 2023 21:32
Copy link
Contributor

@ldennington ldennington left a comment

Choose a reason for hiding this comment

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

Latest commit looks good, just a few small comments. Overall, though, I think this solution is all right until (hopefully) the issue is handled in MSAL.

If we are unable to get a parent window handle; because for example, we
don't have a console, then create a small 'dummy' window using WinForms
that we can use to pass a handle to MSAL.
Update the large block comment on how we select which types of flows to
use for Microsoft authentication.
@mjcheetham
Copy link
Contributor Author

@ldennington I've updated that outdated block comment in _MicrosoftAuthentication.cs`; did you want to have another 👀 over it? Thanks!

Copy link
Contributor

@ldennington ldennington left a comment

Choose a reason for hiding this comment

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

Comment updates look good - thanks for doing that!

@mjcheetham mjcheetham merged commit 75f4e7d into git-ecosystem:main Apr 17, 2023
@mjcheetham mjcheetham deleted the msal-broker-v2 branch April 17, 2023 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth:microsoft Specific to Microsoft AAD/MSA authentication windows-broker Related to the Windows "Web Account Manager" authentication broker

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants