随笔分类 -  .net core jwt

摘要:1:Startup.cs里面的ConfigureServices方法里面添加全局过滤器 services.AddMvc(options => { options.Filters.Add(typeof(ApiAuthorizeFilter)); }); 2:权限过滤器整体校验 public class 阅读全文
posted @ 2022-02-22 10:01 yingxianqi 阅读(1797) 评论(0) 推荐(0) 编辑
摘要:1:生成jwt,此处不能加[Authorize]验证,往往作为登陆接口调用 [Route("/api/Tvl")] [ApiController] public class TvlController : ControllerBase { /// <summary> /// 生成token /// 阅读全文
posted @ 2022-02-21 11:41 yingxianqi 阅读(327) 评论(0) 推荐(0) 编辑
摘要:public class JwtHelper { //生成jwt public static string IssueJwt() { string exp = $"{new DateTimeOffset(DateTime.Now.AddMinutes(120)).ToUnixTimeSeconds( 阅读全文
posted @ 2022-02-18 16:45 yingxianqi 阅读(1249) 评论(0) 推荐(0) 编辑
摘要:前后端分离后,登陆系统后生成一个token,然后将呢个token返给前端,前端每次都要带着这个token进行登陆,否则无法访问后端api接口,后端不用去对比,无需存储token,无需对比,后端自动会识别token是否正确,实现了无状态化的验证(无状态化验证) 但是当验证只能在单设备上登陆的时候,必须 阅读全文
posted @ 2022-02-18 09:59 yingxianqi 阅读(190) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示