From 4c56a43296458bbe5b70d132bc7757e1f923b9a4 Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Mon, 7 Jun 2021 17:05:35 +0800 Subject: [PATCH] Disable audit logs for signalr hub connect/negotiate requests --- .../AspNetCore/SignalR/AbpAspNetCoreSignalRModule.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpAspNetCoreSignalRModule.cs b/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpAspNetCoreSignalRModule.cs index 6b559f4d3e..23fece372f 100644 --- a/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpAspNetCoreSignalRModule.cs +++ b/framework/src/Volo.Abp.AspNetCore.SignalR/Volo/Abp/AspNetCore/SignalR/AbpAspNetCoreSignalRModule.cs @@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; +using Volo.Abp.AspNetCore.Auditing; using Volo.Abp.DependencyInjection; using Volo.Abp.Modularity; @@ -30,6 +31,7 @@ namespace Volo.Abp.AspNetCore.SignalR public override void ConfigureServices(ServiceConfigurationContext context) { + var routePatterns = new List {"/signalr-hubs"}; var signalRServerBuilder = context.Services.AddSignalR(); context.Services.ExecutePreConfiguredActions(signalRServerBuilder); @@ -45,6 +47,8 @@ namespace Volo.Abp.AspNetCore.SignalR foreach (var hubConfig in signalROptions.Hubs) { + routePatterns.AddIfNotContains(hubConfig.RoutePattern); + MapHubType( hubConfig.HubType, endpointContext.Endpoints, @@ -60,6 +64,14 @@ namespace Volo.Abp.AspNetCore.SignalR } }); }); + + Configure(options => + { + foreach (var routePattern in routePatterns) + { + options.IgnoredUrls.AddIfNotContains(x => routePattern.StartsWith(x), () => routePattern); + } + }); } private void AutoAddHubTypes(IServiceCollection services)