Skip to content

Blazor Webassembly Standalone App (No PWA) fails to authenticate using OidcAuthentication due to authorization redirect leaving the browser #61982

Closed as not planned
@webdrivendevelopment

Description

@webdrivendevelopment

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I cannot use OidcAuthentication from a Webassembly Standalone app.
The flow is Auth Code Flow with PKCE.
After being redirected to login form by Blazor app, after successful login, the authorization redirect with auth code in query/fragment (tried both ResponseModes) is not intercepted by Blazor app and shows up in the browser with 404 status code.

Expected Behavior

After performing the aforementioned configuration, the Webassembly Standalone App Oidc Auth (against Keycloak IP) should succeed and user should be in logged in state.

Steps To Reproduce

I am using a Webassembly Standalone App (no PWA) .NET 9 created via Visual Studio 2022.

For Oidc auth, using Microsoft.AspNetCore.Components.WebAssembly.Authentication v9.0.5 (v9.0.4 had same behavior)

The realm and clientId is configured correctly,
I've configured the redirectUris as the default ones from ProviderOptions
(https://localhost:/authorization/login-callback,
https://localhost:/authorization/logout-callback)

For some reason, the Keycloak authorization redirect after login is not intercepted by AuthroizationService.js (whose refernce is added to index.html) / Blazor App and fails with 404 code.

I do have:
Authentication.razor :
@page "/authentication/{action}"
...
and
AuthenticationLoginCallback.razor (to be sure) :
@page "/authentication/login-callback"
...
Redirect still leaving the wasm app...
I tried setting ResponseMode : "fragment" but it didnt' help.

I have seen the sample working on Youtube (e.g. https://www.youtube.com/watch?v=o4_ISZyaUdg) but I cannot get it to work.

I'm exposing the standalone app by referencing its project from a webapi and using the following middleware:

This is the classical SPA-style Oidc Auth scenario and should work.
I followed the official documentation as best as I could, no success yet.

Exceptions (if any)

No response

.NET Version

9.0.300

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Attention 👋This issue needs the attention of a contributor, typically because the OP has provided an update.area-authIncludes: Authn, Authz, OAuth, OIDC, Bearer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions