IdentityServer4 icon indicating copy to clipboard operation
IdentityServer4 copied to clipboard

Claims in HttpContext.User

Open user1336 opened this issue 10 years ago • 3 comments

Hi,

We have an MVC client, Idserver and an API. We want to protect an action in the MVC client controller based on an authorization filter. Upon inspecting the claim type role shows [ "role1", "role2", role3"]

A part of the startup of the MVC client looks like: services.AddAuthorization(options => { options.AddPolicy("Policy1", policy1 => { policy1.RequireAuthenticatedUser(); policy1.RequireClaim("role", "role1"); policy1.RequireClaim("role", "role2"); policy1.RequireClaim("role", "role3"); policy1.Build(); }); });

The protected action in the controller has this attribute [Authorize (Policy = "Policy1")]. Of course this does not match the array of role claims, however in the API the same code/policy is used and the claims are seperated into multiple claims. The policy matches here, as expected. In the user.cs we just add a new claim for each role. {"role": "role1"} {"role": "role2"} {"role":"role3"}

We're not sure this could be related to the access token validation library, maybe dotnet related, the identityserver or even us?

user1336 avatar Oct 27 '16 14:10 user1336

That's a bug in Microsoft's OpenID Connect middleware - will be fixed in ASP.NET Core 1.1 - maybe you need to move to the preview that got released this week.

leastprivilege avatar Oct 27 '16 14:10 leastprivilege

Works!

user1336 avatar Oct 27 '16 14:10 user1336

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 15 '20 10:01 lock[bot]