1

In my JWT I have a list of roles like this: {..., role: "1,2,3", ...}. When my request hits [Authorize(Role = "1")], it returns unauthorized.

Is there a way to parse this comma separated string into an array of roles on my AddAuthentication or AddJwtBearer calls?

1 Answers1

0

You need to use this mapping:

options.ClaimActions.MapJsonKey(JwtClaimTypes.Role, JwtClaimTypes.Role);

instead of

options.ClaimActions.MapUniqueJsonKey(JwtClaimTypes.Role, JwtClaimTypes.Role);

I did write a lengthy post about these problems in a blog post here: Debugging OpenID Connect claim problems in ASP.NET Core

Tore Nestenius
  • 16,431
  • 5
  • 30
  • 40