Blazor WASM application hangs on MSAL Authentication.
See original GitHub issueIs there an existing issue for this?
- I have searched the existing issues
Describe the bug
Same as #38653. When using MSAL authentication in a Blazor WASM application, the login page hangs on the pop-up. Opening the browser’s (specifically Chrome) developer tools causes the pop-up to stop hanging and proceed as normal. Our application was created from the Blazor WASM (PWA) template, no modifications have been done to any of the PWA related scripts.
Expected Behavior
The pop-up shouldn’t hang at all, regardless of whether the developer tools are open or not.
Steps To Reproduce
To get the issue (it’s intermittent as noted in here) we just click our sign-in button, the pop-up appears and just sits there. When this happens, opening the browser’s developer tools does something and causes the pop-up to proceed and close.
// Program.cs
builder.Services
.AddMsalAuthentication<RemoteAuthenticationState, CustomUserAccount>(options =>
{
builder.Configuration.Bind("AzureAd", options.ProviderOptions.Authentication);
options.ProviderOptions.DefaultAccessTokenScopes.Add("https://graph.microsoft.com/openid");
options.UserOptions.RoleClaim = "http://schemas.microsoft.com/ws/2008/06/identity/claims/role";
})
.AddAccountClaimsPrincipalFactory<RemoteAuthenticationState, CustomUserAccount, CustomUserFactory>();
I can provide more details directly to whoever needs to look at it.
Exceptions (if any)
No response
.NET Version
5.0
Anything else?
IDE: Visual Studio 2022 (2019 also seeing the same issue).
Output of dotnet --info
:
$ dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.100
Commit: 9e8b04bbff
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100\
Host (useful for support):
Version: 6.0.0
Commit: 4822e3c3aa
.NET SDKs installed:
6.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:25 (12 by maintainers)
I could get around myself setting the login mode as ‘Redirect’.
... builder.Services .AddMsalAuthentication<RemoteAuthenticationState, CustomUserAccount>(options => {options.ProviderOptions.LoginMode = "redirect";
I can reproduce the problem with this command:
dotnet new blazorwasm -au SingleOrg --api-client-id <guid1> --app-id-uri <guid1> --client-id <guid2> --default-scope my.api.access --domain somedomain.com -ho -o SomeApp --tenant-id <guid3>
First login works. Logout works. Second login hangs.
Opening devtools appears to reliably work around the problem.