Expose MSAL public client builder for embedded WPF sign-in#34
Merged
Conversation
Expose MSAL public client builder for embedded WPF sign-in Windows desktop apps that want the embedded WebView2 sign-in dialog need the Microsoft.Identity.Client.Desktop package, which this netstandard2.1 library cannot reference. Expose the PublicClientApplicationBuilder via a ConfigurePublicClientApplication callback on B2CInteractiveBrowserCredentialOptions so a consuming app can call WithWindowsEmbeddedBrowserSupport(), and add a ParentActivityOrWindow handle to BrowserCustomizationOptions so the dialog is shown modally over the application window. @
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enables Windows desktop consumers (WPF/WinForms) to opt into MSAL’s embedded WebView2 interactive sign-in flow without this netstandard2.1 library directly referencing Microsoft.Identity.Client.Desktop, by exposing the underlying MSAL builder and allowing a parent window handle to be supplied for modal UI ownership.
Changes:
- Expose an optional
ConfigurePublicClientApplicationcallback so consumers can configurePublicClientApplicationBuilder(e.g., callWithWindowsEmbeddedBrowserSupport()from the Desktop package). - Add
BrowserCustomizationOptions.ParentActivityOrWindowand apply it viaWithParentActivityOrWindow(...)during interactive auth. - Add WPF-focused documentation describing the required consumer setup and sample code.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Eryph.GenePool.Client.Authentication/MsalPublicClient.cs | Adds a builder-configuration hook and applies parent-window ownership to interactive auth UI. |
| src/Eryph.GenePool.Client.Authentication/Credentials/B2CInteractiveBrowserCredentialOptions.cs | Introduces ConfigurePublicClientApplication public option with guidance for WebView2 embedded sign-in. |
| src/Eryph.GenePool.Client.Authentication/Credentials/B2CInteractiveBrowserCredential.cs | Wires the new options callback through to the MSAL public client creation. |
| src/Eryph.GenePool.Client.Authentication/BrowserCustomizationOptions.cs | Adds ParentActivityOrWindow option for modal ownership of embedded sign-in UI. |
| docs/wpf-embedded-signin.md | Documents how to enable embedded WebView2 sign-in from a WPF consumer app. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Windows desktop apps that want the embedded WebView2 sign-in dialog need the
Microsoft.Identity.Client.Desktoppackage, which thisnetstandard2.1library cannot reference. This change exposes the underlying MSAL builder so a consuming app can enable the embedded dialog itself:B2CInteractiveBrowserCredentialOptions.ConfigurePublicClientApplication— anAction<PublicClientApplicationBuilder>invoked just before the client is built, so the consumer can callWithWindowsEmbeddedBrowserSupport().BrowserCustomizationOptions.ParentActivityOrWindow— aFunc<IntPtr>applied viaWithParentActivityOrWindow(...)so the dialog is shown modally over the application window.Combined with the existing
UseEmbeddedWebView, these drive the embedded flow. Non-Windows callers leave the new options unset and keep using the system browser. Addeddocs/wpf-embedded-signin.mdwith the consumer setup and a code sample.