Skip to content

Commit

Permalink
Revert "fix: mysql管理密码随机化、密码存储、密码安全规则管理、字符串复杂度检测、生成随机密码、根据id查询账号规则"
Browse files Browse the repository at this point in the history
This reverts commit 161ce83.
  • Loading branch information
iSecloud authored Sep 12, 2023
1 parent 161ce83 commit 6862845
Show file tree
Hide file tree
Showing 30 changed files with 43 additions and 1,632 deletions.
37 changes: 18 additions & 19 deletions dbm-services/common/go-pubpkg/errno/50000_dbpriv_code.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,23 @@ package errno

var (
// dbpriv code start 50000

// PasswordNotConsistent TODO
PasswordNotConsistent = Errno{Code: 51008,
Message: "user is exist,but the new password is not consistent with the old password, should be consistent",
CNMessage: "账号已存在,但是新密码与旧密码不一致,需要保持一致"}
// GrantPrivilegesFail TODO
GrantPrivilegesFail = Errno{Code: 51009, Message: "Grant Privileges Fail", CNMessage: "授权执行失败"}
// GrantPrivilegesSuccess TODO
GrantPrivilegesSuccess = Errno{Code: 0, Message: "Grant Privileges success", CNMessage: "授权执行成功"}
// GrantPrivilegesParameterCheckFail TODO
GrantPrivilegesParameterCheckFail = Errno{Code: 51010, Message: "Parameter of Grant Privileges Check Fail",
CNMessage: "授权单据的参数检查失败"}
// ErrPswNotIdentical TODO
ErrPswNotIdentical = Errno{Code: 51000,
Message: "Password is not identical to the password of existed account rules, " +
"same accounts should use same password.",
CNMessage: "密码与已存在的账号规则中的密码不同,相同账号的密码需要保持一致!"}
// AccountRuleExisted TODO
AccountRuleExisted = Errno{Code: 51001, Message: "Account rule of user on this db is existed ",
CNMessage: "用户对此DB授权的账号规则已存在"}
Expand Down Expand Up @@ -47,8 +57,10 @@ var (
AccountRuleNotExisted = Errno{Code: 51004, Message: "Account rule not existed ", CNMessage: "账号规则不存在"}
// OnlyOneDatabaseAllowed TODO
OnlyOneDatabaseAllowed = Errno{Code: 51005,
Message: "Only one database allowed, database name should not contain space",
CNMessage: "只允许填写一个数据库,数据库名称不能包含空格"}
Message: "Only one database allowed, database name should not contain space", CNMessage: "只允许填写一个数据库,数据库名称不能包含空格"}
// ErrMysqlInstanceStruct TODO
ErrMysqlInstanceStruct = Errno{Code: 51006, Message: "Not either tendbha or orphan structure",
CNMessage: "不符合tendbha或者orphan的集群结构"}
// GenerateEncryptedPasswordErr TODO
GenerateEncryptedPasswordErr = Errno{Code: 51007, Message: "Generate Encrypted Password Err",
CNMessage: "创建账号,生成加密的密码时发生错误"}
Expand All @@ -58,24 +70,11 @@ var (
ClonePrivilegesCheckFail = Errno{Code: 51014, Message: "Clone privileges check fail", CNMessage: "克隆权限检查失败"}
// NoPrivilegesNothingToDo TODO
NoPrivilegesNothingToDo = Errno{Code: 51015, Message: "no privileges,nothing to do", CNMessage: "没有权限需要克隆"}
// IpPortFormatError TODO
IpPortFormatError = Errno{Code: 51017, Message: "format not in 'ip:port' format",
CNMessage: "格式不是ip:port的格式"}
// CloudIdRequired TODO
CloudIdRequired = Errno{Code: 51019, Message: "bk_cloud_id is required", CNMessage: "bk_cloud_id不能为空"}
// ClusterTypeIsEmpty TODO
ClusterTypeIsEmpty = Errno{Code: 51021, Message: "Cluster type can't be empty",
CNMessage: "cluster type不能为空"}
ModifyUserPasswordFail = Errno{Code: 51022, Message: "modify user password fail",
CNMessage: "修改用户密码失败"}
IncludeCharTypesLargerThanLength = Errno{Code: 51023, Message: "include char types larger than length",
CNMessage: "要求包含的字符类型大于字符串长度"}
TryTooManyTimes = Errno{Code: 51024, Message: "try too many times", CNMessage: "尝试太多次"}
RuleIdNull = Errno{Code: 51025, Message: "Rule ID should not be empty",
CNMessage: "安全规则的id不能为空"}
RuleNameNull = Errno{Code: 51026, Message: "Rule name should not be empty",
CNMessage: "安全规则的名称不能为空"}
RuleExisted = Errno{Code: 51027, Message: "Rule already existed ", CNMessage: "规则已存在"}
RuleNotExisted = Errno{Code: 51028, Message: "Rule not existed ", CNMessage: "规则不存在"}
NotMeetComplexity = Errno{Code: 51030, Message: "Set Passwords must meet complexity requirements",
CNMessage: "设置的密码应该符合密码复杂度"}
NameNull = Errno{Code: 51031, Message: "username should not be empty ",
CNMessage: "用户名名称不能为空"}
ClusterTypeIsEmpty = Errno{Code: 51021, Message: "Cluster type can't be empty", CNMessage: "cluster type不能为空"}
)
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ func CreatePartitionTicket(check Checker, objects []PartitionObject, zoneOffset
zone := fmt.Sprintf("%+03d:00", zoneOffset)
ticketType := "MYSQL_PARTITION"
if check.ClusterType == Tendbcluster {
ticketType = "TENDBCLUSTER_PARTITION"
ticketType = "SPIDER_PARTITION"
}
ticket := Ticket{BkBizId: check.BkBizId, TicketType: ticketType, Remark: "auto partition",
Details: Detail{Infos: []Info{{check.ConfigId, check.ClusterId, check.ImmuteDomain, *check.BkCloudId, objects}}}}
Expand Down
3 changes: 1 addition & 2 deletions dbm-services/mysql/db-priv/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,4 @@ pubkey.pem
privkey.pem
infile
outfile
.code.yml
*.log
.code.yml

This file was deleted.

30 changes: 0 additions & 30 deletions dbm-services/mysql/db-priv/assests/migrations/000004_init.up.sql

This file was deleted.

18 changes: 13 additions & 5 deletions dbm-services/mysql/db-priv/handler/account_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (m *PrivService) GetAccountRuleList(c *gin.Context) {
return
}

if err = json.Unmarshal(body, &input); err != nil {
if err := json.Unmarshal(body, &input); err != nil {
slog.Error("msg", err)
SendResponse(c, errno.ErrBind, err)
return
Expand All @@ -51,14 +51,18 @@ func (m *PrivService) AddAccountRule(c *gin.Context) {
return
}

if err = json.Unmarshal(body, &input); err != nil {
if err := json.Unmarshal(body, &input); err != nil {
slog.Error("msg", err)
SendResponse(c, errno.ErrBind, err)
return
}

err = input.AddAccountRule(string(body))
SendResponse(c, err, nil)
if err != nil {
SendResponse(c, err, nil)
return
}
SendResponse(c, nil, nil)
return
}

Expand Down Expand Up @@ -98,13 +102,17 @@ func (m *PrivService) ModifyAccountRule(c *gin.Context) {
return
}

if err = json.Unmarshal(body, &input); err != nil {
if err := json.Unmarshal(body, &input); err != nil {
slog.Error("msg", err)
SendResponse(c, errno.ErrBind, err)
return
}

err = input.ModifyAccountRule(string(body))
SendResponse(c, err, nil)
if err != nil {
SendResponse(c, err, nil)
return
}
SendResponse(c, nil, nil)
return
}
81 changes: 0 additions & 81 deletions dbm-services/mysql/db-priv/handler/admin_password.go

This file was deleted.

45 changes: 0 additions & 45 deletions dbm-services/mysql/db-priv/handler/generate_random_string.go

This file was deleted.

56 changes: 0 additions & 56 deletions dbm-services/mysql/db-priv/handler/randomize_manage.go

This file was deleted.

20 changes: 0 additions & 20 deletions dbm-services/mysql/db-priv/handler/register_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,6 @@ func (m *PrivService) Routes() []*gin.RouteInfo {

// 获取公钥,用于传输过程中加密密码
{Method: http.MethodPost, Path: "pub_key", HandlerFunc: m.GetPubKey},

// 修改实例中指定用户的密码
{Method: http.MethodPost, Path: "modify_mysql_admin_password", HandlerFunc: m.ModifyMysqlAdminPassword},
// 查询密码
{Method: http.MethodPost, Path: "get_password", HandlerFunc: m.GetPassword},
// 修改密码
{Method: http.MethodPost, Path: "modify_password", HandlerFunc: m.ModifyPassword},

// 生成随机字符串
{Method: http.MethodPost, Path: "get_random_string", HandlerFunc: m.GenerateRandomString},

// 安全规则
{Method: http.MethodPost, Path: "get_security_rule", HandlerFunc: m.GetSecurityRule},
{Method: http.MethodPost, Path: "add_security_rule", HandlerFunc: m.AddSecurityRule},
{Method: http.MethodPost, Path: "modify_security_rule", HandlerFunc: m.ModifySecurityRule},
{Method: http.MethodPost, Path: "delete_security_rule", HandlerFunc: m.DeleteSecurityRule},

// 不参与随机化的业务
{Method: http.MethodPost, Path: "get_randomize_exclude", HandlerFunc: m.GetRandomExclude},
{Method: http.MethodPost, Path: "modify_randomize_exclude", HandlerFunc: m.ModifyRandomExclude},
}
}

Expand Down
Loading

0 comments on commit 6862845

Please sign in to comment.