From eef1c3f8566eb0a6ca1554fa8b4373a63c1ca835 Mon Sep 17 00:00:00 2001 From: Ink Date: Fri, 24 Nov 2023 17:55:22 +0800 Subject: [PATCH] fix(jwt): exp field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复没有exp字段时插件的报错 Fix #15 --- preprocess.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/preprocess.go b/preprocess.go index 7d97dec..9a3762d 100644 --- a/preprocess.go +++ b/preprocess.go @@ -114,7 +114,7 @@ func (p *Preprocess) parseJWT(req *http.Request) { } // 3. 验证jwt凭证是否过期 var v map[string]interface{} - if err = json.Unmarshal(payload, &v); err != nil { + if err = json.Unmarshal(payload, &v); err != nil || v["exp"] == nil { return } exp := int64(math.Floor(v["exp"].(float64)))