Skip to content

Commit f0565bb

Browse files
committed
优化WebApi过滤外部访问机制
1 parent 870a667 commit f0565bb

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/Senparc.CO2NET.WebApi/ActionFilters/ForbiddenExternalAccessAsyncFilter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public ForbiddenExternalAccessAsyncFilter(bool forbiddenExternalAccess)
2727

2828
public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
2929
{
30-
if (!_forbiddenExternalAccess && context.HttpContext.Request.IsLocal())
30+
if (_forbiddenExternalAccess && !context.HttpContext.Request.IsLocal())
3131
{
3232
throw new ForbiddenExternalAccessException();
3333
}

src/Senparc.CO2NET.WebApi/Senparc.CO2NET.WebApi.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
4-
<Version>0.2.5.8-preview3</Version>
4+
<Version>0.2.5.9-preview3</Version>
55
<LangVersion>latest</LangVersion>
66
<AssemblyName>Senparc.CO2NET.WebApi</AssemblyName>
77
<RootNamespace>Senparc.CO2NET.WebApi</RootNamespace>

src/Senparc.CO2NET.WebApi/WebApiEngines/WebApiEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public partial class WebApiEngine
6363
/// <param name="showDetailApiLog"></param>
6464
/// <param name="copyCustomAttributes"></param>
6565
/// <param name="defaultAction">默认请求类型,如 Post,Get</param>
66-
/// <param name="forbiddenExternalAccess">是否允许外部访问,默认为 false,只允许本机访问相关 API</param>
66+
/// <param name="forbiddenExternalAccess">是否允许外部访问,默认为 false,只允许本机访问自动生成的 WebApi</param>
6767
public WebApiEngine(string docXmlPath, ApiRequestMethod defaultRequestMethod = ApiRequestMethod.Post, Type baseApiControllerType = null, bool copyCustomAttributes = true, int taskCount = 4, bool showDetailApiLog = false, bool forbiddenExternalAccess = true)
6868
{
6969
_docXmlPath = docXmlPath;

0 commit comments

Comments
 (0)