Skip to content

Commit 8263d70

Browse files
authored
doc(Log): add filter for Antiforgery (#7830)
* revert: 撤销 AddDataProtection 持久化配置 * doc: 增加过滤减少日志
1 parent d49b19e commit 8263d70

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/BootstrapBlazor.Server/Extensions/ServiceCollectionExtensions.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Licensed to the .NET Foundation under one or more agreements.
1+
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the Apache 2.0 License
33
// See the LICENSE file in the project root for more information.
44
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
@@ -18,8 +18,12 @@ public static IServiceCollection AddBootstrapBlazorServerService(this IServiceCo
1818
// 增加中文编码支持网页源码显示汉字
1919
services.AddSingleton(HtmlEncoder.Create(UnicodeRanges.All));
2020

21-
// 增加错误日志
22-
services.AddLogging(logging => logging.AddFileLogger());
21+
// 增加错误日志,并过滤已知的防伪 Token 解密噪音日志
22+
services.AddLogging(logging =>
23+
{
24+
logging.AddFileLogger();
25+
logging.AddFilter("Microsoft.AspNetCore.Antiforgery", LogLevel.None);
26+
});
2327

2428
// 增加多语言支持配置信息
2529
services.AddRequestLocalization<IOptions<BootstrapBlazorOptions>>((localizerOption, blazorOption) =>

src/BootstrapBlazor.Server/Extensions/ServiceCollectionSharedExtensions.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
55

66
using Microsoft.AspNetCore.Components.Authorization;
7-
using Microsoft.AspNetCore.DataProtection;
87

98
namespace Microsoft.Extensions.DependencyInjection;
109

@@ -99,9 +98,7 @@ public static IServiceCollection AddBootstrapBlazorServices(this IServiceCollect
9998
services.AddBootstrapBlazorRegionService();
10099

101100
// 增加密钥存储配置
102-
services.AddDataProtection()
103-
.SetApplicationName("BootstrapBlazor")
104-
.PersistKeysToFileSystem(new DirectoryInfo(Path.Combine(AppContext.BaseDirectory, "keys")));
101+
services.AddDataProtection();
105102

106103
// 增加 PetaPoco ORM 数据服务操作类
107104
// 需要时打开下面代码

0 commit comments

Comments
 (0)