I have a Blazor server app, I implemented cookie auth as shown in: https://www.pragimtech.com/blog/blazor/asp.net-core-identity-setup-in-blazor-application/
I can succesfully protect my page with <AuthorizeView>
and @attribute [Authorize]
.
But I cant get my roles to work, when I use for example: @attribute [Authorize (Roles = "Installer"]
it keeps telling me "Not authorized".
The user and the roles are present in the database (it works with my Blazor WASM project with individual user auth) so I think that cant be the problem.
Did anyone encoutered this problem before??
Do you have something similar to this in your Startup class:
services.AddDefaultIdentity<ApplicationUser>(options =>
options.SignIn.RequireConfirmedAccount = false)
.AddRoles<IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>();