forked from TencentBlueKing/blueking-dbm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend): 授权规则重构 TencentBlueKing#7031
# Reviewed, transaction id: 20592
- Loading branch information
1 parent
ce1c6c7
commit ef5995d
Showing
67 changed files
with
1,238 additions
and
5,108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
96 changes: 96 additions & 0 deletions
96
dbm-ui/frontend/src/services/source/mysqlPermissionAccount.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. | ||
* | ||
* Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at https://opensource.org/licenses/MIT | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | ||
* on 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. | ||
*/ | ||
import MysqlPermissionAccountModel from '@services/model/mysql/mysql-permission-account'; | ||
import type { ListBase } from '@services/types'; | ||
|
||
import { useGlobalBizs } from '@stores'; | ||
|
||
import type { AccountTypesValues } from '@common/const'; | ||
|
||
import http, { type IRequestPayload } from '../http'; | ||
import type { AccountRule, CreateAccountParams, PermissionRule } from '../types/permission'; | ||
|
||
const { currentBizId } = useGlobalBizs(); | ||
|
||
const path = `/apis/mysql/bizs/${currentBizId}/permission/account`; | ||
|
||
/** | ||
* 查询账号规则列表 | ||
*/ | ||
export const getPermissionRules = ( | ||
params: { | ||
limit?: number; | ||
offset?: number; | ||
bk_biz_id: number; | ||
rule_ids?: string; | ||
user?: string; | ||
access_db?: string; | ||
privilege?: string; | ||
account_type?: AccountTypesValues; | ||
}, | ||
payload = {} as IRequestPayload, | ||
) => | ||
http.get<ListBase<MysqlPermissionAccountModel[]>>(`${path}/list_account_rules/`, params, payload).then((res) => ({ | ||
...res, | ||
results: res.results.map((item) => new MysqlPermissionAccountModel(item)), | ||
})); | ||
/** | ||
* 创建账户 | ||
*/ | ||
export const createAccount = (params: CreateAccountParams) => http.post(`${path}/create_account/`, params); | ||
|
||
/** | ||
* 删除账号 | ||
*/ | ||
export const deleteAccount = (params: { bizId: number; account_id: number; account_type?: AccountTypesValues }) => | ||
http.delete(`${path}/delete_account/`, params); | ||
|
||
/** | ||
* 添加账号规则 | ||
*/ | ||
export const createAccountRule = (params: AccountRule & { bk_biz_id: number }) => | ||
http.post(`${path}/add_account_rule/`, params); | ||
|
||
/** | ||
* 修改账号规则 | ||
*/ | ||
export const modifyAccountRule = ( | ||
params: AccountRule & { | ||
rule_id: number; | ||
bk_biz_id: number; | ||
}, | ||
) => http.post(`${path}/modify_account_rule/`, params); | ||
|
||
/** | ||
* 查询账号规则 | ||
*/ | ||
export const queryAccountRules = (params: { user: string; access_dbs: string[]; account_type: AccountTypesValues }) => | ||
http.post<ListBase<PermissionRule[]>>(`${path}/query_account_rules/`, params); | ||
|
||
/** | ||
* 添加账号规则前置检查 | ||
*/ | ||
export const preCheckAddAccountRule = (params: { | ||
account_id: number | null; | ||
access_db: string; | ||
privilege: { | ||
dml: string[]; | ||
ddl: string[]; | ||
glob: string[]; | ||
}; | ||
account_type: AccountTypesValues; | ||
}) => | ||
http.post<{ | ||
force_run: boolean; | ||
warning: string | null; | ||
}>(`${path}/pre_check_add_account_rule/`, params); |
40 changes: 40 additions & 0 deletions
40
dbm-ui/frontend/src/services/source/mysqlPermissionAuthorize.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. | ||
* | ||
* Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at https://opensource.org/licenses/MIT | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | ||
* on 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. | ||
*/ | ||
import http from '../http'; | ||
import type { AuthorizePreCheckData, AuthorizePreCheckResult } from '../types/permission'; | ||
|
||
/** | ||
* 授权规则前置检查 | ||
*/ | ||
export const preCheckAuthorizeRules = (params: AuthorizePreCheckData & { bizId: number }) => | ||
http.post<AuthorizePreCheckResult>(`/apis/mysql/bizs/${params.bizId}/permission/authorize/pre_check_rules/`, params); | ||
|
||
/** | ||
* 权限克隆前置检查 | ||
*/ | ||
export const precheckPermissionClone = (params: { | ||
bizId: number; | ||
clone_type: 'instance' | 'client'; | ||
clone_list: Array<{ source: string; target: string }>; | ||
clone_cluster_type: 'mysql' | 'tendbcluster'; | ||
}) => | ||
http.post<{ | ||
clone_data_list: Array<{ | ||
message: string; | ||
source: string; | ||
target: Array<string> | string; | ||
}>; | ||
clone_uid: string; | ||
message: string; | ||
pre_check: boolean; | ||
}>(`/apis/mysql/bizs/${params.bizId}/permission/clone/pre_check_clone/`, params); |
Oops, something went wrong.