Skip to content

Commit

Permalink
Including PreProcess and PostProcess functions (neo-project#46)
Browse files Browse the repository at this point in the history
* Including PreProcess and PostProcess functions

* Adding pre-post to RpcSecurity
  • Loading branch information
vncoelho authored and 陈志同 committed Oct 13, 2020
1 parent 29d516e commit 80ba2a6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ApplicationLogs/LogReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public override void Configure()
Settings.Load(GetConfiguration());
}

void PreProcess(HttpContext context, string method, JArray _params)
{
}

public JObject OnProcess(HttpContext context, string method, JArray _params)
{
if (method != "getapplicationlog") return null;
Expand All @@ -31,5 +35,9 @@ public JObject OnProcess(HttpContext context, string method, JArray _params)
throw new RpcException(-100, "Unknown transaction");
return JObject.Parse(value.ToString());
}

void PostProcess(HttpContext context, string method, JArray _params, JObject result)
{
}
}
}
8 changes: 8 additions & 0 deletions RpcSecurity/RpcSecurity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ public override void Configure()
Settings.Load(GetConfiguration());
}

void PreProcess(HttpContext context, string method, JArray _params)
{
}

public JObject OnProcess(HttpContext context, string method, JArray _params)
{
if (!CheckAuth(context) || Settings.Default.DisabledMethods.Contains(method))
throw new RpcException(-400, "Access denied");
return null;
}

void PostProcess(HttpContext context, string method, JArray _params, JObject result)
{
}

private bool CheckAuth(HttpContext context)
{
if (string.IsNullOrEmpty(Settings.Default.RpcUser))
Expand Down

0 comments on commit 80ba2a6

Please sign in to comment.