title: Role authorization in .net core 2.0 using Identity throws 404
body: <p>I have .Net Core WebApi application with Identity. Authorization with JWT works good, but after adding role based authorization [Authorize(Roles = "Admin")] throws 404. 
  My GenerateJwtToken method is:</p>
  
  <pre><code>private async Task&lt;object&gt; GenerateJwtToken(string login, IdentityUser user)
      {
          var claims = new List&lt;Claim&gt;
          {
              new Claim(JwtRegisteredClaimNames.Sub, login),
              new Claim(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
              new Claim(ClaimTypes.NameIdentifier, user.Id)
          };
  
          var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration.GetSection("JWTSettings:SecretKey").Value));
          var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
  
          var iss = _configuration.GetSection("JWTSettings:Issuer").Value;
  
          var token = new JwtSecurityToken(
              issuer: _configuration.GetSection("JWTSettings:Issuer").Value,
              audience: _configuration.GetSection("JWTSettings:Audience").Value,
              claims: claims, 
              signingCredentials: creds
              );
  
          return new JwtSecurityTokenHandler().WriteToken(token);
      }
  </code></pre>
  
  <p>ConfigureService from Startup.cs looks like that:</p>
  
  <pre><code> public void ConfigureServices(IServiceCollection services)
      {
          services.AddDbContext&lt;PaszoDbContext&gt;(options =&gt;
              options.UseSqlite("Data Source=PaszoDataBase.db"));
  
  
          services.AddIdentity&lt;IdentityPaszoUser, IdentityRole&gt;(o =&gt; {
              o.Password.RequireDigit = false;
              o.Password.RequiredLength = 1;
              o.Password.RequireLowercase = false;
              o.Password.RequireUppercase = false;
              o.Password.RequireNonAlphanumeric = false;
  
          })
              .AddEntityFrameworkStores&lt;PaszoDbContext&gt;()
              .AddDefaultTokenProviders();
  
  
          JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear(); // =&gt; remove default claims
          services
              .AddAuthentication(options =&gt;
              {
                  options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
  
              })
              .AddJwtBearer(options =&gt;
              {
                  options.RequireHttpsMetadata = false;
                  options.SaveToken = true;
                  options.TokenValidationParameters = new TokenValidationParameters
                  {
                      ValidateIssuerSigningKey = true,
                      IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(Configuration.GetSection("JWTSettings:SecretKey").Value)),
                      ValidateIssuer = true,
                      ValidIssuer = Configuration.GetSection("JWTSettings:Issuer").Value,
                      ValidateAudience = true,
                      ValidAudience = Configuration.GetSection("JWTSettings:Audience").Value,
                      ValidateLifetime = false,
  
                  };
              });
          services.AddMvc();
      }
  </code></pre>
  
  <p>When I test if UserManager recive info about user and role in controller it works  properly:</p>
  
  <pre><code>    [Authorize]//(Roles = "Admin")]
      [HttpGet]
      public List&lt;PaszoUser&gt; GetPaszoUsers()
      {
          var user =  _userManager.GetUserAsync(HttpContext.User).Result;
          var role =_userManager.GetRolesAsync(user).Result;
          ....
  </code></pre>
  
  <p>What to change to make it working?</p>