diff --git a/dbm-ui/frontend/src/services/permission.ts b/dbm-ui/frontend/src/services/permission.ts
index 2998533f5e..edb0a44293 100644
--- a/dbm-ui/frontend/src/services/permission.ts
+++ b/dbm-ui/frontend/src/services/permission.ts
@@ -60,15 +60,39 @@ interface MysqlAdminPasswordResultItem {
port: number
}
+/**
+ * 更新密码策略
+ */
+export interface PasswordPolicyParams {
+ account_type: string,
+ policy: PasswordPolicy
+}
+
+/**
+ * 查询公钥参数
+ */
+export interface RSAPublicKeyParams {
+ names: string[]
+}
+
+/**
+ * 公钥信息
+ */
+export interface RSAPublicKey {
+ content: string,
+ description: string,
+ name: string,
+}
+
/**
* 查询密码安全策略
*/
-export const getPasswordPolicy = () => http.get('/apis/conf/password_policy/get_password_policy/');
+export const getPasswordPolicy = (accountType: string) => http.get('/apis/conf/password_policy/get_password_policy/', { account_type: accountType });
/**
* 更新密码安全策略
*/
-export const updatePasswordPolicy = (params: PasswordPolicy) => http.post('/apis/conf/password_policy/update_password_policy/', params);
+export const updatePasswordPolicy = (params: PasswordPolicyParams) => http.post('/apis/conf/password_policy/update_password_policy/', params);
/**
* 查询随机化周期
@@ -125,18 +149,12 @@ export const queryMysqlAdminPassword = (params: {
/**
* 获取公钥列表
*/
-export const getRSAPublicKeys = (params: {
- names: string[]
-}) => http.post<{
- content: string,
- description: string,
- name: string,
-}[]>('/apis/core/encrypt/fetch_public_keys/', params);
+export const getRSAPublicKeys = (params: RSAPublicKeyParams) => http.post('/apis/core/rsa/fetch_public_keys/', params);
/**
* 校验密码强度
*/
-export const verifyPasswordStrength = (password: string) => http.post('/apis/conf/password_policy/verify_password_strength/', { password });
+export const verifyPasswordStrength = (bizId: number, password: string, accountType?: AccountTypesValues) => http.post(`/apis/mysql/bizs/${bizId}/permission/account/verify_password_strength/`, { password, account_type: accountType });
/**
* 查询账号规则列表
diff --git a/dbm-ui/frontend/src/services/types/permission.ts b/dbm-ui/frontend/src/services/types/permission.ts
index 42f0e3ff5d..f859963620 100644
--- a/dbm-ui/frontend/src/services/types/permission.ts
+++ b/dbm-ui/frontend/src/services/types/permission.ts
@@ -101,18 +101,25 @@ export interface PasswordStrengthVerifyInfo {
// 密码策略
export interface PasswordPolicy {
- id: number,
- name: string,
- rule: {
- include_rule: PasswordPolicyIncludeRule
- exclude_continuous_rule: PasswordPolicyExcludeContinuousRule,
- max_length: number,
- min_length: number,
- },
- creator?: string,
- create_time?: string,
- operator?: string,
- update_time?: string
+ follow: PasswordPolicyFollow,
+ lowercase: boolean,
+ max_length: number,
+ min_length: number,
+ numbers: boolean,
+ symbols: boolean,
+ uppercase: boolean
+}
+
+/**
+ * 密码策略 follow
+ */
+export interface PasswordPolicyFollow {
+ limit: number,
+ letters: boolean,
+ numbers: boolean,
+ repeats: boolean,
+ symbols: boolean,
+ keyboards: boolean
}
// 密码策略 include_rule
diff --git a/dbm-ui/frontend/src/views/mysql/permission/components/AccountDialog.vue b/dbm-ui/frontend/src/views/mysql/permission/components/AccountDialog.vue
index fedeed9f7c..2ccc669b1c 100644
--- a/dbm-ui/frontend/src/views/mysql/permission/components/AccountDialog.vue
+++ b/dbm-ui/frontend/src/views/mysql/permission/components/AccountDialog.vue
@@ -123,8 +123,8 @@
}
type PasswordPolicy = ServiceReturnType;
- type IncludeRule = PasswordPolicy['rule']['include_rule']
- type ExcludeContinuousRule = PasswordPolicy['rule']['exclude_continuous_rule']
+ type IncludeRule = PasswordPolicy
+ type ExcludeContinuousRule = PasswordPolicy['follow']
type PasswordStrength = ServiceReturnType;
type PasswordStrengthVerifyInfo = PasswordStrength['password_verify_info']
@@ -183,7 +183,7 @@
* 获取公钥
*/
function fetchRSAPublicKeys() {
- getRSAPublicKeys({ names: ['password'] })
+ getRSAPublicKeys({ names: ['mysql'] })
.then((res) => {
state.publicKey = res[0]?.content || '';
});
@@ -219,7 +219,7 @@
* 远程校验密码是否符合要求
*/
function verifyPassword() {
- return verifyPasswordStrength(getEncyptPassword())
+ return verifyPasswordStrength(globalbizsStore.currentBizId, getEncyptPassword())
.then((res) => {
passwordState.validate = res;
return res.is_strength;
@@ -230,21 +230,20 @@
* 获取密码安全策略
*/
function fetchPasswordPolicy() {
- getPasswordPolicy()
+ getPasswordPolicy('mysql')
.then((res) => {
const {
min_length: minLength,
max_length: maxLength,
- include_rule: includeRule,
- exclude_continuous_rule: excludeContinuousRule,
- } = res.rule;
+ follow,
+ } = res;
passwordState.strength = [{
keys: ['min_length_valid', 'max_length_valid'],
text: t('密码长度为_min_max', [minLength, maxLength]),
}];
// 常规提示
for (const key of passwordState.keys) {
- if (includeRule[key as keyof IncludeRule]) {
+ if (res[key as keyof IncludeRule]) {
passwordState.strength.push({
keys: [`${key}_valid`],
text: t(PASSWORD_POLICY[key as PasswordPolicyKeys]),
@@ -253,17 +252,17 @@
}
// 重复提示
- if (excludeContinuousRule.repeats) {
+ if (follow.repeats) {
passwordState.strength.push({
keys: ['repeats_valid'],
- text: t('不能连续重复n位字母_数字_特殊符号', { n: excludeContinuousRule.limit }),
+ text: t('不能连续重复n位字母_数字_特殊符号', { n: follow.limit }),
});
}
// 特殊提示(键盘序、字符序、数字序等)
const special = passwordState.followKeys.reduce((values: StrengthItem[], key: string) => {
const valueKey = key.replace('follow_', '') as keyof ExcludeContinuousRule;
- if (excludeContinuousRule[valueKey]) {
+ if (res.follow[valueKey]) {
values.push({
keys: [`${key}_valid`],
text: t(PASSWORD_POLICY[key as PasswordPolicyKeys]),
diff --git a/dbm-ui/frontend/src/views/password-policy/PasswordPolicy.vue b/dbm-ui/frontend/src/views/password-policy/PasswordPolicy.vue
index 5645b6dd2e..68abf84461 100644
--- a/dbm-ui/frontend/src/views/password-policy/PasswordPolicy.vue
+++ b/dbm-ui/frontend/src/views/password-policy/PasswordPolicy.vue
@@ -39,22 +39,22 @@
:label="t('密码必须包含')"
required>
{{ t('小写字母') }}
{{ t('大写字母') }}
{{ t('数字') }}
{{ t('特殊字符_除空格外') }}
@@ -65,33 +65,33 @@
class="password-policy-text mr-8"
style="padding: 0;">N =
{{ t('键盘序') }}
{{ t('字母序') }}
{{ t('数字序') }}
{{ t('连续特殊符号序') }}
{{ t('重复字母_数字_特殊符号') }}
@@ -127,15 +127,7 @@
import { useInfo } from '@hooks';
const initData = () => ({
- max_length: 32,
- min_length: 8,
- include_rule: {
- lowercase: true,
- numbers: true,
- symbols: true,
- uppercase: true,
- },
- exclude_continuous_rule: {
+ follow: {
keyboards: false,
letters: false,
limit: 3,
@@ -143,9 +135,16 @@
repeats: false,
symbols: false,
},
+ lowercase: true,
+ max_length: 32,
+ min_length: 8,
+ numbers: true,
+ symbols: true,
+ uppercase: true,
});
const { t } = useI18n();
+ const accountType = 'mysql';
const passwordPolicyData = {
id: 0,
@@ -158,11 +157,9 @@
const fetchPasswordPolicy = () => {
isLoading.value = true;
- getPasswordPolicy()
+ getPasswordPolicy(accountType)
.then((passwordPolicy) => {
- passwordPolicyData.id = passwordPolicy.id;
- passwordPolicyData.name = passwordPolicy.name;
- Object.assign(formData, passwordPolicy.rule);
+ Object.assign(formData, passwordPolicy);
})
.finally(() => {
isLoading.value = false;
@@ -185,8 +182,8 @@
const handleSubmit = (message = t('保存成功')) => {
isSubmitting.value = true;
updatePasswordPolicy({
- ...passwordPolicyData,
- rule: formData,
+ account_type: accountType,
+ policy: formData,
})
.then(() => {
Message({
diff --git a/dbm-ui/frontend/src/views/password-randomization/Index.vue b/dbm-ui/frontend/src/views/password-randomization/Index.vue
index e6f08c9c27..c630b4e436 100644
--- a/dbm-ui/frontend/src/views/password-randomization/Index.vue
+++ b/dbm-ui/frontend/src/views/password-randomization/Index.vue
@@ -12,7 +12,8 @@
-->
-
+
+