From ec792ffd66a8f6f1b3e53590d2d9be9cdbc9de25 Mon Sep 17 00:00:00 2001 From: yyhenryyy Date: Fri, 22 Nov 2024 20:25:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(mongodb):=20=E8=BF=81=E7=A7=BB=E5=85=83?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E4=BF=9D=E5=AD=98=E5=AF=86=E7=A0=81=E4=B8=8D?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=AF=86=E7=A0=81=E8=A7=84=E5=88=99=20#8135?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flow/utils/mongodb/migrate_meta.py | 2 +- .../flow/utils/mongodb/mongodb_password.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/dbm-ui/backend/flow/utils/mongodb/migrate_meta.py b/dbm-ui/backend/flow/utils/mongodb/migrate_meta.py index 91b66f5791..cfb390312c 100644 --- a/dbm-ui/backend/flow/utils/mongodb/migrate_meta.py +++ b/dbm-ui/backend/flow/utils/mongodb/migrate_meta.py @@ -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], diff --git a/dbm-ui/backend/flow/utils/mongodb/mongodb_password.py b/dbm-ui/backend/flow/utils/mongodb/mongodb_password.py index d749fbf521..2cf84b6aa2 100644 --- a/dbm-ui/backend/flow/utils/mongodb/mongodb_password.py +++ b/dbm-ui/backend/flow/utils/mongodb/mongodb_password.py @@ -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中删除密码