diff --git a/.github/ISSUE_TEMPLATE b/.github/ISSUE_TEMPLATE index 842ffa6..6034a8f 100644 --- a/.github/ISSUE_TEMPLATE +++ b/.github/ISSUE_TEMPLATE @@ -3,7 +3,7 @@ Thank you for reporting an issue. 1. It's RECOMMENDED to submit PR for typo or tiny bug fix. 2. If this's a FEATURE request, please provide: details, pseudo codes if necessary. -3. If this's a BUG, please provide: course repetition, error log and configuration. Fill in as much of the template below as you're able. +3. If this's a BUG, please provide: course repetition, error log and configuration. 感谢您向我们反馈问题。 @@ -12,4 +12,4 @@ Thank you for reporting an issue. 3. 如果是一个新需求,请提供:详细需求描述。 4. 如果是一个 BUG,请提供:复现步骤,错误日志以及相关配置。 5. 如果可能,请使用【英文】来提交,英文 issue 会被优先处理。 ---> \ No newline at end of file +--> diff --git a/README.md b/README.md index 35200d8..d35a417 100644 --- a/README.md +++ b/README.md @@ -253,7 +253,7 @@ services.AddCap(x => }); ``` -The default dashboard address is :[http://localhost:xxx/cap](http://localhost:xxx/cap) , you can also change the `cap` suffix to others with `d.MatchPath` configuration options. +The default dashboard address is :[http://localhost:xxx/cap](http://localhost:xxx/cap), you can also configure the `/cap` suffix with `x.UseDashboard(opt =>{ opt.MatchPath="/mycap"; })`. ![dashboard](http://images2017.cnblogs.com/blog/250417/201710/250417-20171004220827302-189215107.png) diff --git a/docs/content/user-guide/zh/cap/messaging.md b/docs/content/user-guide/zh/cap/messaging.md index 8844b05..bf5c7b8 100644 --- a/docs/content/user-guide/zh/cap/messaging.md +++ b/docs/content/user-guide/zh/cap/messaging.md @@ -32,6 +32,6 @@ CAP 接收到消息之后会将消息进行 Persistent(持久化), 有关 ## 消息数据清理 -数据库消息表中具有一个 ExpiresAt 字段表示消息的过期时间,当消息发送成功或者消费成功后,CAP会将消息状态为 Successed 的 ExpiresAt 设置为 1小时 后过期,会将消息状态为 Failed 的 ExpiresAt 设置为 15天 后过期。 +数据库消息表中具有一个 ExpiresAt 字段表示消息的过期时间,当消息发送成功或者消费成功后,CAP会将消息状态为 Successed 的 ExpiresAt 设置为 1天 后过期,会将消息状态为 Failed 的 ExpiresAt 设置为 15天 后过期。 -CAP 默认情况下会每隔一个小时将消息表的数据进行清理删除,避免数据量过多导致性能的降低。清理规则为 ExpiresAt 不为空并且小于当前时间的数据。 也就是说状态为Failed的消息(正常情况他们已经被重试了 50 次),如果你15天没有人工介入处理,同样会被清理掉。 \ No newline at end of file +CAP 默认情况下会每隔一个小时将消息表的数据进行清理删除,避免数据量过多导致性能的降低。清理规则为 ExpiresAt 不为空并且小于当前时间的数据。 也就是说状态为Failed的消息(正常情况他们已经被重试了 50 次),如果你15天没有人工介入处理,同样会被清理掉。 diff --git a/docs/content/user-guide/zh/transports/kafka.md b/docs/content/user-guide/zh/transports/kafka.md index d3bf7a4..07a5355 100644 --- a/docs/content/user-guide/zh/transports/kafka.md +++ b/docs/content/user-guide/zh/transports/kafka.md @@ -14,7 +14,7 @@ Install-Package DotNetCore.CAP.Kafka ``` -然后,你可以在 `Startup.cs` 的 `ConfigureServices` 方法中添加基于内存的配置项。 +然后,你可以在 `Startup.cs` 的 `ConfigureServices` 方法中添加基于 Kafka 的配置项。 ```csharp diff --git a/docs/content/user-guide/zh/transports/rabbitmq.md b/docs/content/user-guide/zh/transports/rabbitmq.md index 9c08d3d..09b7c7f 100644 --- a/docs/content/user-guide/zh/transports/rabbitmq.md +++ b/docs/content/user-guide/zh/transports/rabbitmq.md @@ -14,7 +14,7 @@ Install-Package DotNetCore.CAP.RabbitMQ ``` -然后,你可以在 `Startup.cs` 的 `ConfigureServices` 方法中添加基于内存的配置项。 +然后,你可以在 `Startup.cs` 的 `ConfigureServices` 方法中添加基于 RabbitMQ 的配置项。 ```csharp @@ -65,4 +65,4 @@ services.AddCap(x => }); }); -``` \ No newline at end of file +``` diff --git a/src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs b/src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs index 543cf33..c8d5e92 100644 --- a/src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs +++ b/src/DotNetCore.CAP.Dashboard/CAP.DashboardMiddleware.cs @@ -97,12 +97,13 @@ namespace DotNetCore.CAP _routes = routes ?? throw new ArgumentNullException(nameof(routes)); } - public Task Invoke(HttpContext context) + public async Task Invoke(HttpContext context) { if (!context.Request.Path.StartsWithSegments(_options.PathMatch, out var matchedPath, out var remainingPath)) { - return _next(context); + await _next(context); + return; } // Update the path @@ -118,23 +119,27 @@ namespace DotNetCore.CAP if (findResult == null) { - return _next.Invoke(context); + await _next.Invoke(context); + return; } - if (_options.Authorization.Any(filter => !filter.Authorize(dashboardContext))) + foreach (var authorizationFilter in _options.Authorization) { + var authenticateResult = await authorizationFilter.AuthorizeAsync(dashboardContext); + if (authenticateResult) continue; + var isAuthenticated = context.User?.Identity?.IsAuthenticated; context.Response.StatusCode = isAuthenticated == true - ? (int) HttpStatusCode.Forbidden - : (int) HttpStatusCode.Unauthorized; + ? (int)HttpStatusCode.Forbidden + : (int)HttpStatusCode.Unauthorized; - return Task.CompletedTask; + return; } dashboardContext.UriMatch = findResult.Item2; - return findResult.Item1.Dispatch(dashboardContext); + await findResult.Item1.Dispatch(dashboardContext); } finally { diff --git a/src/DotNetCore.CAP.Dashboard/IDashboardAuthorizationFilter.cs b/src/DotNetCore.CAP.Dashboard/IDashboardAuthorizationFilter.cs index 0e984ba..2951b14 100644 --- a/src/DotNetCore.CAP.Dashboard/IDashboardAuthorizationFilter.cs +++ b/src/DotNetCore.CAP.Dashboard/IDashboardAuthorizationFilter.cs @@ -1,10 +1,12 @@ // Copyright (c) .NET Core Community. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. +using System.Threading.Tasks; + namespace DotNetCore.CAP.Dashboard { public interface IDashboardAuthorizationFilter { - bool Authorize(DashboardContext context); + Task AuthorizeAsync(DashboardContext context); } } \ No newline at end of file