Skip to content

Blazor Server Side AADB2C AllowAnonymous Not working in latest template #39321

@MetaHex

Description

@MetaHex

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

In the latest template for Blazor Server Side with Microsoft Identity platform. program.cs has:

builder.Services.AddAuthorization(options =>
{
// By default, all incoming requests will be authorized according to the default policy
options.FallbackPolicy = options.DefaultPolicy;
});

So now all pages will direct to login. However, if I want to define a landing page that doesn't require login with

@Attribute [Microsoft.AspNetCore.Authorization.AllowAnonymous], it doesn't work. Page still gets redirected to login.

Maybe this is related to #37064 and #23157

cc: @guardrex per dotnet/AspNetCore.Docs#24473

Expected Behavior

Pages marked with Attribute AllowAnonymous should not be redirected to login if not logged in

Steps To Reproduce

-Start a project with Blazor Server Side with Microsoft Identity Platform.
-Fill in all the required AADB2C configs
-Launch the site to see if AADB2C is setup correctly. clean up (logout)
-go to index.razor or fetchData.razor and add @Attribute [Microsoft.AspNetCore.Authorization.AllowAnonymous]
-Launch site. It still requires AADB2C login on index,razor or fetchData.razor

Exceptions (if any)

No response

.NET Version

6.0.100

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: FixedThe bug or enhancement requested in this issue has been checked-in!area-authIncludes: Authn, Authz, OAuth, OIDC, Bearerarea-blazorIncludes: Blazor, Razor Componentsfeature-blazor-server

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions