且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASP.NET Core 3.1 Web API基于角色的授权不起作用

更新时间:2022-06-02 22:29:32

您需要在身份验证中间件 app.UseAuthorization()之前添加 app.UseAuthentication()将处理JWT承载身份验证,验证和解码令牌,最后写入用户的原则.

You need to add app.UseAuthentication() before app.UseAuthorization() , the authentication middleware will handle the JWT bearer authentication , validate and decode token , at last write to user's principle.