feat: check if the secret in config/share.yml has been changed during registration (#3223)

* feat: check if the secret in config/share.yml has been changed during registration.

* fix: cicd

* fix: code

* fix: cicd

* fix: cicd

* fix: cicd

* fix: cicd

* fix: cicd
This commit is contained in:
icey-yu
2025-03-13 18:21:48 +08:00
committed by GitHub
parent 3516f843db
commit 0b9dbd301c
4 changed files with 38 additions and 11 deletions
+8
View File
@@ -49,6 +49,10 @@ import (
"google.golang.org/grpc"
)
const (
defaultSecret = "openIM123"
)
type userServer struct {
pbuser.UnimplementedUserServer
online cache.OnlineCache
@@ -273,6 +277,10 @@ func (s *userServer) UserRegister(ctx context.Context, req *pbuser.UserRegisterR
if len(req.Users) == 0 {
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 {
return nil, err