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

[Bug] AcquireTokenSilent for OperatingSystemAccount can prompt. #3294

Closed
crmann1 opened this issue Apr 27, 2022 · 1 comment · Fixed by #3306
Closed

[Bug] AcquireTokenSilent for OperatingSystemAccount can prompt. #3294

crmann1 opened this issue Apr 27, 2022 · 1 comment · Fixed by #3306
Assignees
Milestone

Comments

@crmann1
Copy link
Contributor

crmann1 commented Apr 27, 2022

MSAL 4.41 with WAM enabled

We started to see WAM prompts when acquiring the operating system account silently.
In all the cases so far the user was signed into windows with an MSA.

We call

await pca.AcquireTokenSilent(new string[] { defaultConfiguration.GraphEndpoint.AbsoluteUri + ".default" },PublicClientApplication.OperatingSystemAccount)

This ends up calling
WebAuthenticationCoreManagerInterop.RequestTokenForWindowAsync

One interesting thing is the documentation for this API indicates it MAY prompt.
WebAuthenticationCoreManager.RequestTokenAsync Method (Windows.Security.Authentication.Web.Core) - Windows UWP applications | Microsoft Docs
Asynchronously requests a token from a web account provider. If necessary, the user is prompted to enter their credentials.

Microsoft.Identity.Client.Desktop.dll!Microsoft.Identity.Client.Platforms.WebAuthenticationCoreManagerInterop.RequestTokenForWindowAsync(System.IntPtr hWnd, Windows.Security.Authentication.Web.Core.WebTokenRequest request) Line 19
Microsoft.Identity.Client.Desktop.dll!Microsoft.Identity.Client.Platforms.Features.WamBroker.WamProxy.RequestTokenForWindowAsync(System.IntPtr _parentHandle, Windows.Security.Authentication.Web.Core.WebTokenRequest webTokenRequest) Line 73 C#
Microsoft.Identity.Client.Desktop.dll!Microsoft.Identity.Client.Platforms.Features.WamBroker.WamBroker.AcquireTokenSilentDefaultUserPassthroughAsync(Microsoft.Identity.Client.Internal.Requests.AuthenticationRequestParameters authenticationRequestParameters, Windows.Security.Credentials.WebAccountProvider defaultAccountProvider) Line 730 C#
Microsoft.Identity.Client.Desktop.dll!Microsoft.Identity.Client.Platforms.Features.WamBroker.WamBroker.AcquireTokenSilentDefaultUserAsync(Microsoft.Identity.Client.Internal.Requests.AuthenticationRequestParameters authenticationRequestParameters, Microsoft.Identity.Client.ApiConfig.Parameters.AcquireTokenSilentParameters acquireTokenSilentParameters) Line 673 C#
[Completed] Microsoft.Identity.Client.Desktop.dll!Microsoft.Identity.Client.Platforms.Features.WamBroker.WebAccountProviderFactory.GetDefaultProviderAsync() Line 29 C#
[Async] Microsoft.Identity.Client.dll!Microsoft.Identity.Client.Internal.Requests.BrokerSilentStrategy.SendTokenRequestToBrokerAsync() Line 78 C#
[Async] Microsoft.Identity.Client.dll!Microsoft.Identity.Client.Internal.Requests.BrokerSilentStrategy.ExecuteAsync(System.Threading.CancellationToken cancellationToken) Line 49 C#
[Async] Microsoft.Identity.Client.dll!Microsoft.Identity.Client.Internal.Requests.Silent.SilentRequest.ExecuteAsync(System.Threading.CancellationToken cancellationToken) Line 75 C#
[Async] Microsoft.Identity.Client.dll!Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(System.Threading.CancellationToken cancellationToken) Line 88 C#
[Async] Microsoft.Identity.Client.dll!Microsoft.Identity.Client.ApiConfig.Executors.ClientApplicationBaseExecutor.ExecuteAsync(Microsoft.Identity.Client.ApiConfig.Parameters.AcquireTokenCommonParameters commonParameters, Microsoft.Identity.Client.ApiConfig.Parameters.AcquireTokenSilentParameters silentParameters, System.Threading.CancellationToken cancellationToken) Line 41 C#
[Async] Microsoft.Developer.IdentityService.exe!Microsoft.Developer.IdentityService.StorageService.OsTelemetryLogger.PostAccountsSingleSignOnTelemetryAsync.__GetSignedWindowsAccountId|0_2(Microsoft.Identity.Client.IPublicClientApplication pca, System.Diagnostics.TraceSource tracelogger) Line 56 C#

Expectation is that a silent call should be silent and not prompt.

@SameerK-MSFT SameerK-MSFT added this to Triage in MSAL.NET (legacy) via automation Apr 27, 2022
@bgavrilMS bgavrilMS removed the internal label May 2, 2022
@bgavrilMS bgavrilMS moved this from Triage to Estimated/Committed in MSAL.NET (legacy) May 2, 2022
@bgavrilMS bgavrilMS added this to the 4.44.0 milestone May 2, 2022
@bgavrilMS bgavrilMS added P2 and removed P1 labels May 3, 2022
@bgavrilMS
Copy link
Member

bgavrilMS commented May 5, 2022

For MSA-PT apps, we need to use a transfer token between MSA and AAD. As such, the WAM API RequestTokenForWindowAsync is correctly used, because WAM's AcquireTokenSilently needs a web account, but this web account cannot be obtained in MSA-PT scenarios. The transfer token guarantees that RequestTokenForWindowAsync is silent, but 2 things can go wrong:

  1. We don't actually get a transfer token. In this case, MSAL should throw an UiRequiredException and not continue with RequestTokenForWindowAsync
  2. There is something wrong at the protocol level

I will provide a fix for the first issue, but for the second one we'd need a repro, e.g. an account affected by this, or at least a correlation id + timestamp (but ideally an account).

@bgavrilMS bgavrilMS moved this from Estimated/Committed to In Progress in MSAL.NET (legacy) May 5, 2022
@bgavrilMS bgavrilMS self-assigned this May 5, 2022
bgavrilMS added a commit that referenced this issue May 5, 2022
MSAL.NET (legacy) automation moved this from In Progress to Fixed May 11, 2022
bgavrilMS added a commit that referenced this issue May 11, 2022
#3306)

* Fix for #3294 - throw UiRequiredException when WAM cannot get a transfer token in MSA-PT

* Address PR
pmaytak pushed a commit that referenced this issue May 12, 2022
#3306)

* Fix for #3294 - throw UiRequiredException when WAM cannot get a transfer token in MSA-PT

* Address PR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
3 participants