mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
feat: check if the secret in config/share.yml has been changed during registration.
This commit is contained in:
parent
e76e02fdba
commit
ca12e25e91
@ -49,6 +49,10 @@ import (
|
|||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
defaultSecret = "openIM123"
|
||||||
|
)
|
||||||
|
|
||||||
type userServer struct {
|
type userServer struct {
|
||||||
pbuser.UnimplementedUserServer
|
pbuser.UnimplementedUserServer
|
||||||
online cache.OnlineCache
|
online cache.OnlineCache
|
||||||
@ -273,6 +277,10 @@ func (s *userServer) UserRegister(ctx context.Context, req *pbuser.UserRegisterR
|
|||||||
if len(req.Users) == 0 {
|
if len(req.Users) == 0 {
|
||||||
return nil, errs.ErrArgs.WrapMsg("users is empty")
|
return nil, errs.ErrArgs.WrapMsg("users is empty")
|
||||||
}
|
}
|
||||||
|
// check if secret is changed
|
||||||
|
if s.config.Share.Secret == defaultSecret {
|
||||||
|
return nil, servererrs.ErrSecretNotChanged.Wrap()
|
||||||
|
}
|
||||||
|
|
||||||
if err = authverify.CheckAdmin(ctx, s.config.Share.IMAdminUserID); err != nil {
|
if err = authverify.CheckAdmin(ctx, s.config.Share.IMAdminUserID); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -37,7 +37,10 @@ const (
|
|||||||
|
|
||||||
// General error codes.
|
// General error codes.
|
||||||
const (
|
const (
|
||||||
NoError = 0 // No error
|
NoError = 0 // No error
|
||||||
|
|
||||||
|
SecretNotChangedError = 50 // secret not changed
|
||||||
|
|
||||||
DatabaseError = 90002 // Database error (redis/mysql, etc.)
|
DatabaseError = 90002 // Database error (redis/mysql, etc.)
|
||||||
NetworkError = 90004 // Network error
|
NetworkError = 90004 // Network error
|
||||||
DataError = 90007 // Data error
|
DataError = 90007 // Data error
|
||||||
|
@ -17,6 +17,8 @@ package servererrs
|
|||||||
import "github.com/openimsdk/tools/errs"
|
import "github.com/openimsdk/tools/errs"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
ErrSecretNotChanged = errs.NewCodeError(SecretNotChangedError, "secret not changed, please change secret in config/share.yml for security reasons")
|
||||||
|
|
||||||
ErrDatabase = errs.NewCodeError(DatabaseError, "DatabaseError")
|
ErrDatabase = errs.NewCodeError(DatabaseError, "DatabaseError")
|
||||||
ErrNetwork = errs.NewCodeError(NetworkError, "NetworkError")
|
ErrNetwork = errs.NewCodeError(NetworkError, "NetworkError")
|
||||||
ErrCallback = errs.NewCodeError(CallbackError, "CallbackError")
|
ErrCallback = errs.NewCodeError(CallbackError, "CallbackError")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user