Commit 04a42619 authored by Savorboard's avatar Savorboard

Fix build error

parent 9c3c6a9f
// Copyright (c) .NET Core Community. All rights reserved. // Copyright (c) .NET Core Community. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information. // Licensed under the MIT License. See License.txt in the project root for license information.
using System.Threading.Tasks;
using DotNetCore.CAP.Internal; using DotNetCore.CAP.Internal;
namespace DotNetCore.CAP.Dashboard namespace DotNetCore.CAP.Dashboard
{ {
public class LocalRequestsOnlyAuthorizationFilter : IDashboardAuthorizationFilter public class LocalRequestsOnlyAuthorizationFilter : IDashboardAuthorizationFilter
{ {
public bool Authorize(DashboardContext context) public Task<bool> AuthorizeAsync(DashboardContext context)
{ {
var ipAddress = context.Request.RemoteIpAddress; var ipAddress = context.Request.RemoteIpAddress;
// if unknown, assume not local // if unknown, assume not local
if (string.IsNullOrEmpty(ipAddress)) if (string.IsNullOrEmpty(ipAddress))
{ {
return false; return Task.FromResult(false);
} }
// check if localhost // check if localhost
if (ipAddress == "127.0.0.1" || ipAddress == "0.0.0.1") if (ipAddress == "127.0.0.1" || ipAddress == "0.0.0.1")
{ {
return true; return Task.FromResult(true);
} }
// compare with local address // compare with local address
if (ipAddress == context.Request.LocalIpAddress) if (ipAddress == context.Request.LocalIpAddress)
{ {
return true; return Task.FromResult(true);
} }
// check if private ip // check if private ip
if (Helper.IsInnerIP(ipAddress)) if (Helper.IsInnerIP(ipAddress))
{ {
return true; return Task.FromResult(true);
} }
return false; return Task.FromResult(false);
} }
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment