Skip to content

Commit

Permalink
fix(backend): 去掉授权兼容参数 TencentBlueKing#8211
Browse files Browse the repository at this point in the history
  • Loading branch information
iSecloud authored and hLinx committed Dec 9, 2024
1 parent b8f2423 commit b651aa6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -950,4 +950,4 @@ def authorize_sub_flow(root_id: str, uid: str, bk_biz_id: int, operator: str, ru
}
act_lists.append(act)
sub_pipeline.add_parallel_acts(acts_list=act_lists)
return sub_pipeline.build_sub_process(sub_name=_("权限克隆"))
return sub_pipeline.build_sub_process(sub_name=_("授权执行"))
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from backend.db_services.dbpermission.db_authorize.models import DBRuleActionLog
from backend.flow.engine.bamboo.engine import BambooEngine
from backend.flow.plugins.components.collections.common.base_service import BaseService
from backend.ticket.constants import TicketType

logger = logging.getLogger("flow")

Expand Down Expand Up @@ -88,12 +87,12 @@ def _execute(self, data, parent_data, callback=None) -> bool:
ticket_id = kwargs["uid"]
bk_biz_id = kwargs["bk_biz_id"]
# TODO: 参数兼容,后续去掉
db_type = kwargs.get("db_type") or TicketType.get_db_type_by_ticket(kwargs["ticket_type"])
db_type = kwargs.get("db_type")
user_db_rules_map = kwargs.get("user_db_rules_map")
operator = kwargs.get("operator") or kwargs.get("created_by")
operator = kwargs.get("operator")
# authorize_data, 格式为:
# {"user": xx, "source_ip": [...], "target_instances": [...], "access_db": [...]}
authorize_data = kwargs.get("authorize_data") or kwargs["rules_set"][0]
authorize_data = kwargs.get("authorize_data")

# 授权规则记录
self._generate_rule_logs(bk_biz_id, db_type, operator, authorize_data, user_db_rules_map)
Expand Down
26 changes: 14 additions & 12 deletions dbm-ui/backend/tests/mock_data/ticket/ticket_params_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,33 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""
from backend.configuration.constants import DBType
from backend.db_services.mysql.permission.constants import CloneClusterType
from backend.ticket.constants import TicketType

BASE_FLOW_PARAMS = {
"uid": 1,
"root_id": "4146d614abf011",
"ticket_type": "",
"created_by": "admin",
"bk_biz_id": 1,
}

MYSQL_AUTHORIZE_FLOW_PARAMS = {
**BASE_FLOW_PARAMS,
"db_type": DBType.MySQL.value,
"ticket_type": TicketType.MYSQL_AUTHORIZE_RULES.value,
"rules_set": [
{
"bk_biz_id": 1,
"operator": "admin",
"user": "admin",
"access_dbs": ["datamain"],
"account_rules": [{"dbname": "datamain", "bk_biz_id": 1}],
"source_ips": ["127.0.0.1", "127.0.0.2"],
"target_instances": ["gamedb.privtest55.blueking.db"],
"cluster_type": "tendbha",
}
],
"operator": "admin",
"authorize_data": {
"bk_biz_id": 1,
"operator": "admin",
"user": "admin",
"access_dbs": ["datamain"],
"account_rules": [{"dbname": "datamain", "bk_biz_id": 1}],
"source_ips": ["127.0.0.1", "127.0.0.2"],
"target_instances": ["gamedb.privtest55.blueking.db"],
"cluster_type": "tendbha",
},
}

MYSQL_CLONE_FLOW_PARAMS = {
Expand Down

0 comments on commit b651aa6

Please sign in to comment.