title: Jwt Role authentication in controller ASP.net core 2.1
body: <p>I am writing a cooperative web API with asp.net core 2.1 using postgresql as db. after the user sign in user is given a JWT token that will be use for the front end side authentication (Front end will be implemented with angular 2+). I want to store the user role in JWT and when the user sign In, user role will be read from the db and it will be store (authorize Role) So I will write Roles on the controller method. I want to use the Authorize attribute. </p>
  
  <pre><code>   // Auth Controller
      [HttpGet("GetUsers")]
      [Authorize(Roles = "admin")]
      public ActionResult GetUsers()
      {
          var users = _authRepository.GetUsers();
          return Ok(users);
      }
  </code></pre>
  
  <p>and Repository.cs</p>
  
  <pre><code>public List&lt;User&gt; GetUsers()
  {
      var users = _context.Users.ToList();
      return users;
  }
  </code></pre>
  
  <p><strong><em>Question:</em></strong> Do I need to write a middleware to read each user role from JWT and a put that role to the Identity Principal Claims? Please share your experince. I will be glad to know your approch.</p>