From 0f6893d1741840c4a120d67815b85601d0adc7bb Mon Sep 17 00:00:00 2001 From: NoahLan <6995syu@163.com> Date: Mon, 6 May 2024 14:53:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E5=90=AF=E5=8A=A8?= =?UTF-8?q?=E9=A1=B9=EF=BC=8C=E6=B7=BB=E5=8A=A0=E6=97=A0=E6=84=9Ftoken?= =?UTF-8?q?=E5=88=B7=E6=96=B0=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=89=B4=E6=9D=83?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=9D=9E=E5=BC=80=E5=8F=91=E7=8E=AF?= =?UTF-8?q?=E5=A2=83=E9=99=90=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/NPin.Web/NPinWebModule.cs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/NPin.Web/NPinWebModule.cs b/src/NPin.Web/NPinWebModule.cs index 68c1e21..6548d35 100644 --- a/src/NPin.Web/NPinWebModule.cs +++ b/src/NPin.Web/NPinWebModule.cs @@ -15,6 +15,7 @@ using NPin.Framework.AspNetCore.Microsoft.AspNetCore.Builder; using NPin.Framework.AspNetCore.Microsoft.Extensions.DependencyInjection; using NPin.Framework.TenantManagement.Application; using NPin.Framework.Upms.Application; +using NPin.Framework.Upms.Domain.Authorization; using NPin.Framework.Upms.Domain.Shared.Consts; using NPin.Framework.Upms.Domain.Shared.Options; using NPin.SqlSugarCore; @@ -249,13 +250,24 @@ public class NPinWebModule : AbpModule public override Task OnApplicationInitializationAsync(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); - + var env = context.GetEnvironment(); + app.UseRouting(); // Cors app.UseCors(DefaultCorsPolicyName); - // TODO 无感Token refresh + // 非开发环境,开启限流 + if (!env.IsDevelopment()) + { + app.UseRateLimiter(); + } + + // 无感Token刷新,先刷新再鉴权 + app.UseRefreshToken(); + + // 鉴权 + app.UseAuthentication(); // 多租户 app.UseMultiTenancy(); @@ -277,10 +289,10 @@ public class NPinWebModule : AbpModule // 授权 app.UseAuthorization(); - // 审计 + // 审计日志 app.UseAuditing(); - // 日志 + // 日志记录 app.UseAbpSerilogEnrichers(); // 终端节点