Blazor WASM Not Redirecting to Login Page

Viewed 33

I am new to Blazor and trying to authenticate using oidc. I am trying to use the instructions from Secure an ASP.NET Core Blazor WebAssembly standalone app to set it up.

Here is what I want the app to do (this, I think is a 'normal' app flow):

  1. Start app
  2. Be redirected to a login page (this login page is not within my app)
  3. After login redirect back to app

I must be missing something simple. When I try to run the app I see this error in the Browser Console errors:

Refused to display 'https://xxxx.yyyy.com/' in a frame because it set 'X-Frame-Options' to 'deny'.

In the response headers, I see this:

X-Frame-Options: DENY

X-MS-Forwarded-Status-Code: 500

And in the request headers:

Sec-Fetch-Dest: iframe Sec-Fetch-Mode: navigate Sec-Fetch-Site: cross-site

I am trying to emulate an existing, working Angular app and in that app headers, I see this in the header

Sec-Fetch-Dest: document

Sec-Fetch-Mode: navigate

Sec-Fetch-Site: cross-site

I'm not sure if that difference in the header is the difference or not but it's the only thing I see. Looking for advice on how to get this login flow working?

1 Answers

It turns out my scenario - Blazor Webassembly to ADFS is not supported. After days of banging my head, I found this: BLAZOR WASM - ADFS - OIDC - Documentation indicating this is not a supported scenario.

I then found article which pointed me in the correct direction Configure Blazor WASM with ADFS

Turns out the MSAL provider seems to work fine for this scenario:

builder.Services.AddMsalAuthentication(options => {
// Configure your authentication provider options here.
options.ProviderOptions.Authentication.Authority = "https://xxx.yyyy.com/adfs";
options.ProviderOptions.Authentication.ClientId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx";
options.ProviderOptions.Authentication.NavigateToLoginRequestUrl = true;
options.ProviderOptions.LoginMode = "redirect";

});

Related