From 8a5bb7be35d1df7d434c01d9c4f3cc8bee0c75b3 Mon Sep 17 00:00:00 2001 From: skiffer-git <44203734@qq.com> Date: Mon, 18 Apr 2022 21:29:48 +0800 Subject: [PATCH] add operationID when ws connecting --- cmd/Open-IM-SDK-Core | 2 +- internal/msg_gateway/gate/ws_server.go | 2 +- pkg/common/token_verify/jwt_token.go | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/Open-IM-SDK-Core b/cmd/Open-IM-SDK-Core index 3ecd23203..fd87b4bfc 160000 --- a/cmd/Open-IM-SDK-Core +++ b/cmd/Open-IM-SDK-Core @@ -1 +1 @@ -Subproject commit 3ecd23203cd6bd746b1fcb0c70755bd2cbf5361c +Subproject commit fd87b4bfc3ee7e9f4c50140b884eb4505d00bc44 diff --git a/internal/msg_gateway/gate/ws_server.go b/internal/msg_gateway/gate/ws_server.go index 7686b6cab..18f507c42 100644 --- a/internal/msg_gateway/gate/ws_server.go +++ b/internal/msg_gateway/gate/ws_server.go @@ -271,7 +271,7 @@ func (ws *WServer) headerCheck(w http.ResponseWriter, r *http.Request) bool { // e := err.(*constant.ErrInfo) log.Error(operationID, "Token verify failed ", "query ", query, msg, err.Error()) w.Header().Set("Sec-Websocket-Version", "13") - http.Error(w, err.Error(), 2001) + http.Error(w, err.Error(), status) return false } else { log.Info(operationID, "Connection Authentication Success", "", "token", query["token"][0], "userID", query["sendID"][0]) diff --git a/pkg/common/token_verify/jwt_token.go b/pkg/common/token_verify/jwt_token.go index 16eb5e8d0..e58424623 100644 --- a/pkg/common/token_verify/jwt_token.go +++ b/pkg/common/token_verify/jwt_token.go @@ -218,13 +218,13 @@ func VerifyToken(token, uid string) (bool, error) { func WsVerifyToken(token, uid string, platformID string) (bool, error, string) { claims, err := ParseToken(token, "") if err != nil { - return false, utils.Wrap(err, ""), "parse token err" + return false, utils.Wrap(err, "parse token err"), "parse token err" } if claims.UID != uid { - return false, utils.Wrap(&constant.ErrTokenUnknown, ""), "uid is not same to token uid" + return false, utils.Wrap(&constant.ErrTokenUnknown, "uid is not same to token uid"), "uid is not same to token uid" } if claims.Platform != constant.PlatformIDToName(utils.StringToInt32(platformID)) { - return false, utils.Wrap(&constant.ErrTokenUnknown, ""), "platform is not same to token platform" + return false, utils.Wrap(&constant.ErrTokenUnknown, "platform is not same to token platform"), "platform is not same to token platform" } log.NewDebug("", claims.UID, claims.Platform) return true, nil, ""