Blazor WASM Standalone: 404 error on Logout using AD B2C and MSAL

891 Views Asked by At

I have a Blazor 5 client-side application using AD B2C and MSAL that throws a 404 error when calling /authentication/logout-callback.

Blazor B2C MSAL Logout Error

When running the app locally this works as expected. This issue occurs when deploying the app to Azure Blob storage as a static site. Login works as expected when deployed to Blob storage static sites and logging out actually works, if you manually navigate back to Home from the 404 page, the user is logged out.

Within the Azure AD B2C app registration the following are set:

  • API Permissions for Microsoft Azure AD B2C App Registration API Permissions

  • Authentication Redirect URIs Azure AD B2C App Registration Redirect URIs

The following is the app configuration. enter image description here

The app was created using the following template without any additional modifications:

dotnet new blazorwasm -au IndividualB2C --aad-b2c-instance "${AAD B2C INSTANCE}" --api-client-id "${SERVER API APP CLIENT ID}" --app-id-uri "${SERVER API APP ID URI}" --client-id "${CLIENT APP CLIENT ID}" --default-scope "${DEFAULT SCOPE}" --domain "${TENANT DOMAIN}" -ho -o "${APP NAME}" -ssp "${SIGN UP OR SIGN IN POLICY}"

Why is the app generating a 404 error when logging out? I'm not sure if this is a configuration issue within the app, Azure B2C, or something related to Azure Blob static sites.

Is there a way to retrieve error debug information on the RemoteAuthenticatorView component? Chrome's DevTools doesn't provide much insight. enter image description here

1

There are 1 best solutions below

1
PaulWaldman On

This issue is due to the way Azure Storage Blob Static sites serves content. Direct sub-links come back with 404 because Static sites is looking for static content files.

I'm not sure what the difference is between the login redirect working, but not the logout redirect. I did try to add the logout redirect in the B2C app permissions, but that didn't improve things.

Ultimately adding Index.html as the error page within Static sites "fixed" this issue. This isn't the most ideal UX because the entire page becomes refreshed and the other page components close and reopen.

enter image description here