Pārlūkot izejas kodu

新增 DecryptSign 方法并修改时间戳校验逻辑

在 TestController 中新增 DecryptSign 方法,该方法接收一个字符串参数 sign 并返回该字符串。
在 IdentityDomainService 中修改时间戳校验逻辑,改为判断 request.Timestamp 与当前时间 now 的差值是否大于3秒。
xf 4 nedēļas atpakaļ
vecāks
revīzija
812b8dd7ae

+ 5 - 0
src/Hotline.Api/Controllers/TestController.cs

@@ -1537,5 +1537,10 @@ public class TestController : BaseController
 
         return ipv4;
     }
+
+    public string DecryptSign(string sign)
+    {
+        return sign;
+    }
 }
 

+ 1 - 1
src/Hotline/Identity/IdentityDomainService.cs

@@ -32,7 +32,7 @@ public class IdentityDomainService : IIdentityDomainService, IScopeDependency
         if (string.IsNullOrEmpty(request.Nonce)) return false;
         var now = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
         _logger.LogInformation($"now:{now}, req:{request.Timestamp}");
-        if (request.Timestamp > now) return false;
+        if ((request.Timestamp - now) > 3) return false;
         if ((now - request.Timestamp) >= 60) return false;
         var nonce = _cacheAccountNonce.Get(request.Username)?.Nonce;
         _logger.LogInformation($"nonce:{nonce}, reqnonce:{request.Nonce}");