| | |
| | | using System.Web.Http; |
| | | using System.Web.Http.Controllers; |
| | | using System.Web.Http.Filters; |
| | | using WebAPI; |
| | | using WebAPI.Service; |
| | | |
| | | namespace project.Filter |
| | |
| | | } |
| | | var currentTs = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds; |
| | | var diff = Math.Abs(currentTs - ts); |
| | | |
| | | if (diff > 300) // 300秒 = 5分钟 |
| | | { |
| | | actionContext.Response = actionContext.Request.CreateResponse(System.Net.HttpStatusCode.BadRequest, |
| | |
| | | } |
| | | rawData = rawData.Replace("'", "%27"); |
| | | var signStr = rawData + "×tamp=" + timestamp + "&nonce=" + nonce + "&key=" + SecretKey; |
| | | |
| | | var serverSign = ComputeHmacSha256(signStr, SecretKey); |
| | | |
| | | |
| | | |
| | | if (serverSign != clientSign.ToUpper()) |
| | | { |
| | | actionContext.Response = actionContext.Request.CreateResponse(System.Net.HttpStatusCode.Unauthorized, |