authenticationactive-directoryazure-active-directorysingle-sign-onwebview2

WebView2 - SSO, Recognize Login, or Persist Cookies/Identity


I am running into an issue, working win WebView2 in a WPF application.

The one complaint we are getting from users is that the MS login gets 'forgotten' after the browser window closes, requiring that they login via a popup MS window on subsequent webview loads, and click on their identity. If a webview2 app that has already stored the user identity is open, it seems to reuse that authentication.

Is there a way to persist that login, so that after the window closes, subsequent windows reuse that login, along with maybe an expiration on the file(s) that have that information?

Some thoughts:

I've already tried setting the environment variable for AllowSingleSignOnUsingOSPrimaryAccount, but that didn't work.

It is using Fixed Binaries, so passing a relative path.

var options = new CoreWebView2EnvironmentOptions(default, default, default, true);
string installPath = @"./Microsoft.WebView2.FixedVersionRuntime.91.0.864.48.x86";
CoreWebView2Environment env = await CoreWebView2Environment.CreateAsync(installPath, userFolder, options);
 
await this.webView.EnsureCoreWebView2Async(env);

Solution

  • There were two solutions to this problem:

    1. For the web browser persistence, after the initlal authentication, JS in the WPF app would find the necessary section on the MS login and click it for the user.

    2. For other applications, Imprivata, an app integral to these desktops, would persist the user login and add the credentials for them.