From fe477dad8ab1d889892b31032335cf10041bb2c9 Mon Sep 17 00:00:00 2001 From: cKey <35512826+colinin@users.noreply.github.com> Date: Fri, 29 Apr 2022 19:52:20 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3signalr=E8=BA=AB=E4=BB=BD?= =?UTF-8?q?=E4=BB=A4=E7=89=8C.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...RealtimeMessageHttpApiHostModule.Configure.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs index 592a73bdb..07acc3bec 100644 --- a/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs +++ b/aspnet-core/services/LY.MicroService.RealtimeMessage.HttpApi.Host/RealtimeMessageHttpApiHostModule.Configure.cs @@ -20,6 +20,7 @@ using System.Collections.Generic; using System.Linq; using System.Text.Encodings.Web; using System.Text.Unicode; +using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Auditing; using Volo.Abp.Caching; @@ -315,6 +316,21 @@ public partial class RealtimeMessageHttpApiHostModule options.Authority = configuration["AuthServer:Authority"]; options.RequireHttpsMetadata = false; options.Audience = configuration["AuthServer:ApiName"]; + options.Events = new JwtBearerEvents + { + OnMessageReceived = context => + { + if (context.Token.IsNullOrWhiteSpace()) + { + var accessToken = context.Request.Query["access_token"]; + if (!accessToken.IsNullOrEmpty()) + { + context.Token = accessToken; + } + } + return Task.CompletedTask; + } + }; }); if (!isDevelopment)