From 0589c29e5db2b0eda116554e553a498b221a2d22 Mon Sep 17 00:00:00 2001 From: luolan Date: Wed, 16 Jul 2025 21:58:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0JWT=E8=AE=A4=E8=AF=81?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E6=97=B6=E7=9A=84=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E5=93=8D=E5=BA=94=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AGSS/Program.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/AGSS/Program.cs b/AGSS/Program.cs index 73e4532..b9c11e9 100644 --- a/AGSS/Program.cs +++ b/AGSS/Program.cs @@ -83,6 +83,17 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme) ValidateIssuerSigningKey = true, IssuerSigningKey = secKey }; + x.Events = new JwtBearerEvents + { + OnChallenge = context => + { + context.HandleResponse(); + context.Response.StatusCode = 200; + context.Response.ContentType = "application/json"; + return context.Response.WriteAsJsonAsync(new ReturnTemplate(401,"你提供了一个错误的Token,所以我们无法验证你的身份,唔......",null)); + } + + }; }) .AddCookie("Identity.External").AddCookie("Identity.Application");