CommunityToolkit / Graph-Controls

Set of Helpers and Controls for Windows development using the Microsoft Graph.
https://docs.microsoft.com/en-us/windows/communitytoolkit/graph/overview
Other
154 stars 39 forks source link

[Feature] Add functionality to use AAD B2C authentication #186

Open tnsturm opened 2 years ago

tnsturm commented 2 years ago

AAD-B2C-specifics

Please add some overloads to MSALProvider constructor and GetTokenAsync:

AAD B2C needs the bold marked specifics:

application = PublicClientApplicationBuilder.Create(ClientID) .WithB2CAuthority(Authority) .Build();

and

await application.GetAccountsAsync( B2CPolicySignUpSignIn );

ghost commented 2 years ago

Hello tnsturm, thank you for opening an issue with us!

I have automatically added a "needs triage" label to help get things started. Our team will analyze and investigate the issue, and escalate it to the relevant team if possible. Other community members may also look into the issue and provide feedback 🙌

michael-hawker commented 2 years ago

@tnsturm I believe you're talking about this API here?

I believe this requires us to update our dependency to enable, though I know there's a change in how MSAL is packaged, so I'm not familiar with which side of that gap we're on.

Not sure if @shweaver-MSFT remembers.

shweaver-MSFT commented 2 years ago

I suggest either:

  1. Create the PublicClientApplication object externally and pass it into the constructor. https://github.com/CommunityToolkit/Graph-Controls/blob/15513b1861d6fa016165e61867c08ec05c0a70a0/CommunityToolkit.Authentication.Msal/MsalProvider.cs#L63

  2. Extend MsalProvider and override the CreatePublicClientApplication function to add this functionality. Something like a "B2CMsalProvider". You can reference the original method to see how we do it and add in the line you need: https://github.com/CommunityToolkit/Graph-Controls/blob/15513b1861d6fa016165e61867c08ec05c0a70a0/CommunityToolkit.Authentication.Msal/MsalProvider.cs#L187

If you still think this would make a good addition to the toolkit and have the energy, I'd love someone to take a second look at the problem, think about the issue, propose a fix and put up a PR. Let us know if that sounds interesting to you and feel free to continue the conversation here in this issue :)