From bb0170dfb974c86e8d4200f6f4001812a16ec984 Mon Sep 17 00:00:00 2001 From: dengbiao Date: Thu, 26 Dec 2024 22:55:37 +0800 Subject: [PATCH] 1 --- app/lib/aes/check.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/lib/aes/check.go b/app/lib/aes/check.go index 1354ae6..707dbc5 100644 --- a/app/lib/aes/check.go +++ b/app/lib/aes/check.go @@ -77,8 +77,20 @@ func CheckSign(c *gin.Context) error { if err != nil { return err } - if currentTimestamp-storedTimestamp > 300 { // 5分钟 - return fmt.Errorf("签名过期!") + if currentTimestamp-storedTimestamp < 0 { + //TODO::兼容客户端传毫秒 + currentTimestamp = time.Now().UnixMilli() + if currentTimestamp-storedTimestamp > 60*2*1000 { // 2分钟 + return fmt.Errorf("签名过期!") + } + } else { + if currentTimestamp-storedTimestamp > 60*2 { // 2分钟 + return fmt.Errorf("签名过期!") + } + } + + if currentTimestamp-storedTimestamp < 0 { + return errors.New("签名有误!") } return nil }