瀏覽代碼

Fix build error

master
Savorboard 4 年之前
父節點
當前提交
04a42619ac
共有 1 個檔案被更改,包括 7 行新增6 行删除
  1. +7
    -6
      src/DotNetCore.CAP.Dashboard/LocalRequestsOnlyAuthorizationFilter.cs

+ 7
- 6
src/DotNetCore.CAP.Dashboard/LocalRequestsOnlyAuthorizationFilter.cs 查看文件

@@ -1,40 +1,41 @@
// 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;
using DotNetCore.CAP.Internal;

namespace DotNetCore.CAP.Dashboard
{
public class LocalRequestsOnlyAuthorizationFilter : IDashboardAuthorizationFilter
{
public bool Authorize(DashboardContext context)
public Task<bool> AuthorizeAsync(DashboardContext context)
{
var ipAddress = context.Request.RemoteIpAddress;
// if unknown, assume not local
if (string.IsNullOrEmpty(ipAddress))
{
return false;
return Task.FromResult(false);
}

// check if localhost
if (ipAddress == "127.0.0.1" || ipAddress == "0.0.0.1")
{
return true;
return Task.FromResult(true);
}

// compare with local address
if (ipAddress == context.Request.LocalIpAddress)
{
return true;
return Task.FromResult(true);
}

// check if private ip
if (Helper.IsInnerIP(ipAddress))
{
return true;
return Task.FromResult(true);
}

return false;
return Task.FromResult(false);
}
}
}

Loading…
取消
儲存