Skip to content

MapRazorComponents broken with FallbackPolicy RequireAuthenticatedUser #51836

Open
@davhdavh

Description

@davhdavh

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

It seems fallback policy is broken for all blazor modes.

services.AddAuthorization(o => o.FallbackPolicy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build());
...
app.UseStaticFiles();
app.UseAuth...();
app.MapRazorComponents<App>()
   .AddInteractiveServerRenderMode();

results in a redirect to login when requesting /_framework/blazor.web.js.

services.AddAuthorization(o => o.FallbackPolicy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build());
...
app.UseStaticFiles();
app.MapRazorComponents<App>()
   .AddInteractiveServerRenderMode();
app.UseAuth...();

ALSO results in a redirect to login when requesting /_framework/blazor.web.js.

Expected Behavior

Putting Maps before UseAuth... => no auth check
Putting Maps after UseAuth... => auth check for pages, but not for staticfiles

Steps To Reproduce

See above

Exceptions (if any)

No

.NET Version

8.0.100-rc.2.23502.2

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions