iplimit代理放行

This commit is contained in:
“wanyongkang”
2021-11-16 09:05:54 +08:00
parent 0649843b6d
commit 370fcb2976

View File

@@ -19,7 +19,6 @@ namespace Hncore.Infrastructure.WebApi
public override void OnAuthorization(AuthorizationFilterContext context)
{
if (context.AllowAnonymous()
|| context.HasPassed()
|| !context.HasTokenAuthInfo())
@@ -27,11 +26,25 @@ namespace Hncore.Infrastructure.WebApi
return;
}
if (context.HttpContext.Request.GetManageUserInfo() == null)
var manager_user_info = context.HttpContext.Request.GetManageUserInfo();
if (manager_user_info == null)
{
context.Reject();
}
var IP = context.HttpContext.Request.Headers["X-Real-IP"].ToString();
System.IO.StreamReader reader = new System.IO.StreamReader("/var/www/ip/ip");
string limitIp = reader.ReadLine();
//LogHelper.Error("ipaddresses", (!limitIp.Contains(IP)).ToString());
if ((!limitIp.Contains(IP)) && manager_user_info.OperaterId<100000) {
context.Reject();
}
context.SetPassed("ManageAuth");
}
}