From e616136f33ffcea00673c93bb118cc85116d9599 Mon Sep 17 00:00:00 2001 From: withchao <993506633@qq.com> Date: Sun, 11 Jun 2023 11:46:42 +0800 Subject: [PATCH] WsVerifyToken --- pkg/common/tokenverify/jwt_token.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/common/tokenverify/jwt_token.go b/pkg/common/tokenverify/jwt_token.go index 378c99540..4666ddab7 100644 --- a/pkg/common/tokenverify/jwt_token.go +++ b/pkg/common/tokenverify/jwt_token.go @@ -89,5 +89,15 @@ func IsManagerUserID(opUserID string) bool { return utils.IsContain(opUserID, config.Config.Manager.AppManagerUid) } func WsVerifyToken(token, userID, platformID string) error { + claim, err := GetClaimFromToken(token) + if err != nil { + return err + } + if claim.UID != userID { + return errs.ErrTokenInvalid.Wrap(fmt.Sprintf("token uid %s != userID %s", claim.UID, userID)) + } + if claim.Platform != platformID { + return errs.ErrInternalServer.Wrap(fmt.Sprintf("token platform %s != platformID %s", claim.Platform, platformID)) + } return nil }