Blog Posts for: Json Web Tokens

Using Roles with the ASP.NET Core JWT middleware

12 July 2016

Here is a great find: The JWT middleware in ASP.NET Core knows how to interpret a “roles” claim inside your JWT payload, and will add the appropriate claims to the ClaimsIdentity. This makes using the [Authorize] attribute with Roles very easy. This is best demonstrated with a simple example. First of all I head over to and create a JSON Web Token with the following payload: {"iss":"","aud":"blog-readers","sub":"123456","exp":1499863217,"roles":["Admin","SuperUser"]} Note the array of roles in the “roles” claim.