I am using Azure AD role based authentication, I have added 2 roles ( Observer, Reader ) which are assigned to specific users which works fine. The manifest file has these 2 new entries in it. All the authentication is working normally, but I cannot get the User.IsInRole() to return true, always returns false
I have added the following code to the Startup.cs
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = SettingsHelper.ClientId,
Authority = String.Format(CultureInfo.InvariantCulture,SettingsHelper.AADInstance, SettingsHelper.TenantId),
PostLogoutRedirectUri = SettingsHelper.PostLogoutRedirectUri,
TokenValidationParameters = new System.IdentityModel.Tokens.TokenValidationParameters
{
// map the claimsPrincipal's roles to the roles claim
RoleClaimType = "roles",
},
}
When I query User.IsInRole("Observer") it returns false. I can see the claim in my debug session of User
{http://schemas.microsoft.com/ws/2008/06/identity/claims/role: Observer}
But not able to access it, is this a common problem am I doing something wrong?
Here is my USER session var
RoleClaimType = "http://schemas.microsoft.com/ws/2008/06/identity/claims/role"
? – juunashttp://schemas.microsoft.com/ws/2008/06/identity/claims/role
notrole
. – juunas