How to use JWT for asp.net Core

跟風遠走 提交于 2019-12-31 03:43:09

问题


I follow JWT Authentication for Asp.Net Web Api answer to add JWT to my asp.net core project but System.Web.Http.Filters is not supported in .net core??

any better solution for securing web API ???


回答1:


Filters are supported in ASP.NET Core MVC. You can find them in Microsoft.AspNetCore.Mvc.Filters namespace. Take a look at this guide for example.

Bear in mind that you don't need to implement JWT authentication filter yourself. This has already been implemented as part of Microsoft.AspNetCore.Authentication.JwtBearer NuGet package. All you need is to use a JwtBearerAuthentication middleware in your app by adding app.UseJwtBearerAuthentication(new JwtBearerOptions { /* options */ }) to Startup.Configure() method.



来源:https://stackoverflow.com/questions/43697313/how-to-use-jwt-for-asp-net-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!