iplimit代理放行
This commit is contained in:
@@ -19,7 +19,6 @@ namespace Hncore.Infrastructure.WebApi
|
|||||||
|
|
||||||
public override void OnAuthorization(AuthorizationFilterContext context)
|
public override void OnAuthorization(AuthorizationFilterContext context)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (context.AllowAnonymous()
|
if (context.AllowAnonymous()
|
||||||
|| context.HasPassed()
|
|| context.HasPassed()
|
||||||
|| !context.HasTokenAuthInfo())
|
|| !context.HasTokenAuthInfo())
|
||||||
@@ -27,11 +26,25 @@ namespace Hncore.Infrastructure.WebApi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context.HttpContext.Request.GetManageUserInfo() == null)
|
var manager_user_info = context.HttpContext.Request.GetManageUserInfo();
|
||||||
|
|
||||||
|
if (manager_user_info == null)
|
||||||
{
|
{
|
||||||
context.Reject();
|
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");
|
context.SetPassed("ManageAuth");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user