diff --git a/HMACAuthentication.WebApi/Filters/HMACAuthenticationAttribute.cs b/HMACAuthentication.WebApi/Filters/HMACAuthenticationAttribute.cs index 18c6da3..b581c0d 100644 --- a/HMACAuthentication.WebApi/Filters/HMACAuthenticationAttribute.cs +++ b/HMACAuthentication.WebApi/Filters/HMACAuthenticationAttribute.cs @@ -151,8 +151,9 @@ private bool isReplayRequest(string nonce, string requestTimeStamp) var serverTotalSeconds = Convert.ToUInt64(currentTs.TotalSeconds); var requestTotalSeconds = Convert.ToUInt64(requestTimeStamp); + ulong difference = serverTotalSeconds > requestTotalSeconds ? serverTotalSeconds - requestTotalSeconds : requestTotalSeconds - serverTotalSeconds; - if ((serverTotalSeconds - requestTotalSeconds) > requestMaxAgeInSeconds) + if (difference > requestMaxAgeInSeconds) { return true; }