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

Update MsalProvider to use native account broker #169

Merged
merged 12 commits into from
Oct 25, 2021

Conversation

shweaver-MSFT
Copy link
Member

@shweaver-MSFT shweaver-MSFT commented Oct 12, 2021

Fixes #168
Fixes #170

PR Type

What kind of change does this PR introduce?

  • Feature

What is the current behavior?

Currently the MsalProvider does not invoke the native account broker in Windows, even when it is available. Users always see the web-based prompt, even when using the MsalProvider in UWP.

What is the new behavior?

I've made a few changes:

  1. Updated the CommunityToolkit.Authentication.Msal package to multi-target uap10.0, netstandard3.1, and net5.0-windows10.0.17763.0 as well as the existing target for netstandard2.0. This enables the Windows account broker to work for those additional frameworks.
  2. Updated the MsalProvider to use the appropriate APIs depending on where the app is running (UWP/Net5-Windows or otherwise).
  3. Added a new constructor for MsalProvider that accepts a pre-configured PublicClientApplication object.
  4. Added a new sample to demonstrate using MsalProvider in NetCore3.1 applications.
  5. Updated MsalNet5WindowsMsalProviderSample to show token cache pattern.

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tested code with current supported SDKs
  • Sample in sample app has been added / updated (for bug fixes / features)
  • Tests for the changes have been added (for bug fixes / features) (if applicable)
  • Header has been added to all new source files (run build/UpdateHeaders.bat)
  • Contains NO breaking changes

Other information

A good way to test is by firing up the UwpMsalProviderSample, WpfNet5WindowsMsalProviderSample, and WpfNetCoreMsalProviderSample samples and compare the experience.

More info on the cache situation can be found here: https://github.com/AzureAD/microsoft-authentication-extensions-for-dotnet/wiki/Cross-platform-Token-Cache

@ghost
Copy link

ghost commented Oct 12, 2021

Thanks shweaver-MSFT for opening a Pull Request! The reviewers will test the PR and highlight if there is any merge conflict or changes required. If the PR is approved we will proceed to merge the pull request 🙌

Copy link

@XAML-Knight XAML-Knight left a comment

Choose a reason for hiding this comment

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

Looks good - the UWP experience is much more natural than the WPF one :(

CommunityToolkit.Authentication.Msal/MsalProvider.cs Outdated Show resolved Hide resolved
@shweaver-MSFT shweaver-MSFT merged commit 33f781a into main Oct 25, 2021
@shweaver-MSFT shweaver-MSFT deleted the shweaver/msal-broker branch October 25, 2021 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants