Skip to content

Commit

Permalink
fix(mongodb): 迁移元数据保存密码不使用密码规则 #8135
Browse files Browse the repository at this point in the history
  • Loading branch information
yyhenryyy authored and iSecloud committed Nov 25, 2024
1 parent 0589e60 commit ec792ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dbm-ui/backend/flow/utils/mongodb/migrate_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def save_password(self):

for username in self.info["usernames"]:
for password_info in self.info["password_infos"]:
result = MongoDBPassword().save_password_to_db(
result = MongoDBPassword().save_password_to_db2(
instances=password_info["nodes"],
username=username,
password=password_info["password"][username],
Expand Down
19 changes: 19 additions & 0 deletions dbm-ui/backend/flow/utils/mongodb/mongodb_password.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,25 @@ def save_password_to_db(self, instances: list, username: str, password: str, ope
else:
return ""

def save_password_to_db2(self, instances: list, username: str, password: str, operator: str) -> str:
"""不使用密码规则把密码保存到db中"""

result = DBPrivManagerApi.modify_password(
{
"instances": instances,
"username": username,
"component": self.component,
"password": self.base64_encode(password),
"operator": operator,
"security_rule_name": "",
},
raw=True,
)
if result["code"] != RequestResultCode.Success.value:
return result["message"]
else:
return ""

def delete_password_from_db(self, instances: list, usernames: list) -> str:
"""
从db中删除密码
Expand Down

0 comments on commit ec792ff

Please sign in to comment.