You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my Razor components I can authenticate users adding the [Authorize] attribute.
However, User.IsInRole does not work, as it apparantly looks for claims with the type http://schemas.microsoft.com/ws/2008/06/identity/claims/role.
Roles in the principal are actually in the roles claim.
Shouldn't this be set to the correct value by default?
Is there a way to override this?
Reproduction steps
Create a new Blazor app
Configure authentication with builder.Services.AddMicrosoftIdentityWebAppAuthentication(builder.Configuration) in Program.cs
Add [Authorize] to a component, and verify only authenticated users have access.
Add a role to the attribute [Authorize(Roles = "Whatever")] and make sure the user has this role assigned in Microsoft Entra.
Observe the user is now denied access, even though the role is included in the roles claim.
Error message
No response
Id Web logs
No response
Relevant code snippets
Seeabove.
Regression
No response
Expected behavior
The role claim type should be set correctly by default.
The text was updated successfully, but these errors were encountered:
Microsoft.Identity.Web Library
Microsoft.Identity.Web
Microsoft.Identity.Web version
3.5.0
Web app
Sign-in users
Web API
Not Applicable
Token cache serialization
Not Applicable
Description
I have added authentication to an ASP.NET Core Blazor application (
net9.0
) like this:In my Razor components I can authenticate users adding the
[Authorize]
attribute.However,
User.IsInRole
does not work, as it apparantly looks for claims with the typehttp://schemas.microsoft.com/ws/2008/06/identity/claims/role
.Roles in the principal are actually in the
roles
claim.Reproduction steps
builder.Services.AddMicrosoftIdentityWebAppAuthentication(builder.Configuration)
inProgram.cs
[Authorize]
to a component, and verify only authenticated users have access.[Authorize(Roles = "Whatever")]
and make sure the user has this role assigned in Microsoft Entra.roles
claim.Error message
No response
Id Web logs
No response
Relevant code snippets
Regression
No response
Expected behavior
The role claim type should be set correctly by default.
The text was updated successfully, but these errors were encountered: