mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
add ParseToken rpc
This commit is contained in:
parent
93f3dd14a5
commit
c1811463cb
@ -56,6 +56,19 @@ func (rpc *rpcAuth) UserToken(_ context.Context, req *pbAuth.UserTokenReq) (*pbA
|
|||||||
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{}, Token: tokens, ExpiredTime: expTime}, nil
|
return &pbAuth.UserTokenResp{CommonResp: &pbAuth.CommonResp{}, Token: tokens, ExpiredTime: expTime}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (rpc *rpcAuth) ParseToken(_ context.Context, req *pbAuth.ParseTokenReq) (*pbAuth.ParseTokenResp, error) {
|
||||||
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String())
|
||||||
|
claims, err := token_verify.ParseToken(req.Token, req.OperationID)
|
||||||
|
if err != nil {
|
||||||
|
errMsg := "ParseToken failed " + err.Error() + req.OperationID + " token " + req.Token
|
||||||
|
log.Error(req.OperationID, errMsg, "token:", req.Token)
|
||||||
|
return &pbAuth.ParseTokenResp{CommonResp: &pbAuth.CommonResp{ErrCode: 4001, ErrMsg: errMsg}}, nil
|
||||||
|
}
|
||||||
|
resp := pbAuth.ParseTokenResp{CommonResp: &pbAuth.CommonResp{}, UserID: claims.UID, Platform: claims.Platform, ExpireTimeSeconds: uint32(claims.ExpiresAt.Unix())}
|
||||||
|
log.Info(req.OperationID, utils.GetSelfFuncName(), " rpc return ", resp.String())
|
||||||
|
return &resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (rpc *rpcAuth) ForceLogout(_ context.Context, req *pbAuth.ForceLogoutReq) (*pbAuth.ForceLogoutResp, error) {
|
func (rpc *rpcAuth) ForceLogout(_ context.Context, req *pbAuth.ForceLogoutReq) (*pbAuth.ForceLogoutResp, error) {
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String())
|
||||||
if !token_verify.IsManagerUserID(req.OpUserID) {
|
if !token_verify.IsManagerUserID(req.OpUserID) {
|
||||||
|
@ -1 +0,0 @@
|
|||||||
package auth
|
|
File diff suppressed because it is too large
Load Diff
@ -50,7 +50,7 @@ message ParseTokenReq{
|
|||||||
|
|
||||||
message ParseTokenResp{
|
message ParseTokenResp{
|
||||||
string userID = 1;
|
string userID = 1;
|
||||||
string operationID = 2;
|
string platform = 2;
|
||||||
CommonResp commonResp = 3;
|
CommonResp commonResp = 3;
|
||||||
uint32 expireTimeSeconds = 4;
|
uint32 expireTimeSeconds = 4;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user