.Net Core JWT Authentication with custom API Key Middleware

后端 未结 1 977
攒了一身酷
攒了一身酷 2020-12-31 17:46

I have a .Net Core 2.0 application that uses JWT tokens to authorize the user. This all works fine but I want to have some sort of API Key mechanism to allow other applicati

相关标签:
1条回答
  • 2020-12-31 17:56

    Applying Claim("role", "Admin") to GenericPrincipal will not affect anything, because GenericPrincipal have nothing to do with Role Claims. So if you want to apply admin role to GenericPrincipal, you need to add it in constructor parameter:

     var principal = new GenericPrincipal(identity, new[] {"Admin","ApiUser"});
     context.User = principal;
    
    0 讨论(0)
提交回复
热议问题