From 02a3e38c9e42ad9ccd6d4c5a9e7a4ab894d3574f Mon Sep 17 00:00:00 2001 From: izory <791736813@qq.com> Date: Thu, 23 Sep 2021 10:56:22 +0800 Subject: [PATCH] =?UTF-8?q?=E7=99=BB=E5=BD=95=20jwt=20token=E8=B6=85?= =?UTF-8?q?=E6=97=B6=E5=A2=9E=E5=8A=A0=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZR.Admin.WebApi/Framework/JwtUtil.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ZR.Admin.WebApi/Framework/JwtUtil.cs b/ZR.Admin.WebApi/Framework/JwtUtil.cs index e75abff..1f7f073 100644 --- a/ZR.Admin.WebApi/Framework/JwtUtil.cs +++ b/ZR.Admin.WebApi/Framework/JwtUtil.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Http; +using Infrastructure; +using Microsoft.AspNetCore.Http; using Microsoft.IdentityModel.Tokens; using Newtonsoft.Json; using System; @@ -43,12 +44,13 @@ namespace ZR.Admin.WebApi.Framework { var tokenHandler = new JwtSecurityTokenHandler(); var key = Encoding.ASCII.GetBytes(KEY); + var expires = ConfigUtils.Instance.GetAppConfig("sysConfig:tokenExpire", 10); var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(claims), //Issuer = "", //Audience = "", - Expires = DateTime.Now.AddDays(7), + Expires = DateTime.Now.AddMinutes(expires), SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature) }; var token = tokenHandler.CreateToken(tokenDescriptor);