-
Notifications
You must be signed in to change notification settings - Fork 54
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
I need to be able to set "AllowSingleSignOnUsingOSPrimaryAccount = true" for single sign on in a UWP app #4103
Comments
There is a workaround discussed here: #747. Does this work for you? |
I tested the workaround, and it didn't work for my scenario. Any ETA for a proper fix? |
@jeremiahjordanisaacson Regarding adding support for From a functional point of view, CoreWebView2EnvironmentOptions options = new CoreWebView2EnvironmentOptions()
{
AllowSingleSignOnUsingOSPrimaryAccount = true
}; and, Environment.SetEnvironmentVariable("WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS", "--enable-features=msSingleSignOnOSForPrimaryAccountIsShared"); essentially do the same thing under the hood. They are just two different ways to enable the same feature. It looks like there may be a problem with SSO and MSA accounts in UWP apps (AAD enterprise login is working as expected though). Are you seeing the issue with MSA accounts (ie. when navigating to sites like https://login.live.com)? |
@pieths-ms I'm getting the "You can't get there from here." message when attempting to use the code suggested. In my WPF app, it works though. Any ETA on a fix? Code I used: |
@jeremiahjordanisaacson, what type of account are you using for sign-in: MSA or AAD? Are you seeing the error with both types of accounts or just one of them? |
@pieths-ms AAD. |
@jeremiahjordanisaacson Have you enabled the following capability in your UWP app? enterpriseCloudSSO (Enterprise Cloud Single Sign On: The enterpriseCloudSSO capability allows apps to use single sign on with Azure Active Director (AAD) resources inside a hosted web view control). See here for more details regarding Depending on what your app needs with respect to authentication, the following may also be useful: |
@pieths-ms It's not working. I was missing the suggestion above for the enterprise auth setting, so I made the update, tested, and no luck. I attempted to create an entirely new project from scratch following all recommended guidance but alas still not working. Any idea how to resolve? Notice, also added the environment setting: Notice, the WebView2 browser is working - just auth isn't when I switch out www.bing.com for a corporate website needing authentication. The error continues when testing with my corporate website that requires authentication. |
@jeremiahjordanisaacson From the screenshot you shared above, it looks like you have only added the Enterprise Cloud Single Sign On: The enterpriseCloudSSO capability allows apps to use single sign on with Azure Active Directory (AAD) resources inside a hosted web view control |
The <Capabilities>
<Capability Name="internetClient" />
<uap:Capability Name="enterpriseAuthentication"/>
<uap:Capability Name="sharedUserCertificates"/>
<!-- Try adding this one -->
<rescap:Capability Name="enterpriseCloudSSO" />
</Capabilities> Also requires adding the following to the list of available namespaces in the main "Package" tag: xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" Here is the <Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap mp rescap"> |
@pieths-ms Eureka! It worked! Holy buckets that's a buried capability. Thank you so much for the help! |
@jeremiahjordanisaacson Awesome! Glad you got it working. |
For anyone interested, our UWP app was just rejected for the MS store for including the restricted capability described here (enterpriseCloudSSO), after explaining the use case and referencing comments made here in github explaining that it is the only way to get it to work. The feedback given was this: In our case WebView2 is being redirected to resources protected by Microsoft Active Directory auth that uses Microsoft Entra Conditional Access policies requiring a device Id. We have no control over when our customers may be directed to use this kind of resource. Does their feedback make sense? How can we augment WebView2 to invoke some secondary process when it sees Microsoft authentication is required? |
@pieths-ms This seems like it's going to be an ongoing concern for folks trying to release in the MS Store. @sparkrod Has a point. |
Hi @sparkrod , @jeremiahjordanisaacson . MSAL has dropped support for UWP. It looks like the WAM (Web Account Manager) APIs might be the best way forward. When the app gets a token from WAM, it should be able to just use that token to access the site, whether the site requires conditional access or not. The app has to find a proper way to use that token in WebView. For OAuth 2, the app would have to ensure that http header “Authorization: Bearer ” is set when WebView2 sends the http request. There are WebView2 API for the app to modify http request headers to achieve this. Hope this helps guide you in the right direction. Please let me know if you have any questions. Thanks. |
Thanks for following up! I will look into WAM, but I think that still leaves me with a couple of questions- |
Describe the feature/enhancement you need
I read the below and it appears I can't do this today. It seems like a pretty critical feature especially with the "Device ID" block for Azure AD. Please let me know if there is a work around for a C# UWP app that wants to use WebView2 with Single Sign On.
API limitations
The following classes aren't accessible in WinUI 2 or WinUI 3:
CoreWebView2EnvironmentOptions
CoreWebView2ControllerOptions
The scenario/use case where you would use this feature
This would allow application users to automatically sign into a modern application. Not having this feature means that I have to revert to building a .NET WPF app. I don't think that's the direction you want developers to go.
How important is this request to you?
Critical. My app's basic functions wouldn't work without it.
Suggested implementation
Fix this:
API limitations
The following classes aren't accessible in WinUI 2 or WinUI 3:
CoreWebView2EnvironmentOptions
CoreWebView2ControllerOptions
What does your app do? Is there a pending deadline for this request?
Access an internal site that I don't own but requires corporate AAD to access. ASAP
AB#48742778
The text was updated successfully, but these errors were encountered: