Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor wasm Authentication with Roles

$
0
0

I'm looking into implementing authentication in a client side Blazor application with wasm.

Microsoft has a sample for exactly that scenario, but - not very confidence inspiring - it seems broken: https://github.com/dotnet/blazor-samples/tree/main/10.0/BlazorWebAssemblyStandaloneWithIdentity

Building the sample application with the latest .NET 10 SDK and logging in with a normal user without permissions I can access the private manager page:

enter image description here

The Authentication seems to be working generally - I can only access the page if I'm logged in, but it seems to ignore the Roles parameter:

@page "/private-manager-page"@attribute [Authorize(Roles = "Manager")]@using System.Security.Claims

The [documentation for blazor authentication](https://learn.microsoft.com/en-us/aspnet/core/blazor/security/?view=aspnetcore-10.0&tabs=visual-studio#troubleshoot-errors) implies that I can solve this by adding builder.Services.AddCascadingAuthenticationState(); but doing so makes no difference.

What is missing from the sample or is there some local configuration that's missing?


Viewing all articles
Browse latest Browse all 4839

Trending Articles