diff --git a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostIdentityCreateRequest.java b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostIdentityCreateRequest.java index e5f2e415..1b30d977 100644 --- a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostIdentityCreateRequest.java +++ b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostIdentityCreateRequest.java @@ -27,6 +27,7 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.dromara.visor.framework.web.core.annotation.ParamDecrypt; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; @@ -61,7 +62,7 @@ public class HostIdentityCreateRequest implements Serializable { @Schema(description = "用户名") private String username; - @Size(max = 512) + @ParamDecrypt @Schema(description = "用户密码") private String password; diff --git a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostIdentityQueryRequest.java b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostIdentityQueryRequest.java index e814f08b..3c473b78 100644 --- a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostIdentityQueryRequest.java +++ b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostIdentityQueryRequest.java @@ -61,10 +61,6 @@ public class HostIdentityQueryRequest extends PageRequest { @Schema(description = "用户名") private String username; - @Size(max = 512) - @Schema(description = "用户密码") - private String password; - @Schema(description = "密钥id") private Long keyId; diff --git a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostIdentityUpdateRequest.java b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostIdentityUpdateRequest.java index ed05421b..037a946d 100644 --- a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostIdentityUpdateRequest.java +++ b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostIdentityUpdateRequest.java @@ -28,6 +28,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import org.dromara.visor.common.security.UpdatePasswordAction; +import org.dromara.visor.framework.web.core.annotation.ParamDecrypt; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; @@ -66,7 +67,7 @@ public class HostIdentityUpdateRequest implements UpdatePasswordAction { @Schema(description = "用户名") private String username; - @Size(max = 512) + @ParamDecrypt @Schema(description = "用户密码") private String password; diff --git a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostKeyCreateRequest.java b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostKeyCreateRequest.java index 340f8e6c..f4ec71cd 100644 --- a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostKeyCreateRequest.java +++ b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostKeyCreateRequest.java @@ -27,6 +27,7 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; +import org.dromara.visor.framework.web.core.annotation.ParamDecrypt; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; @@ -51,14 +52,16 @@ public class HostKeyCreateRequest implements Serializable { @Schema(description = "名称") private String name; + @ParamDecrypt @Schema(description = "公钥文本") private String publicKey; @NotBlank + @ParamDecrypt @Schema(description = "私钥文本") private String privateKey; - @Size(max = 512) + @ParamDecrypt @Schema(description = "密码") private String password; diff --git a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostKeyUpdateRequest.java b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostKeyUpdateRequest.java index 4a4a5b0f..79580606 100644 --- a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostKeyUpdateRequest.java +++ b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/entity/request/host/HostKeyUpdateRequest.java @@ -28,6 +28,7 @@ import lombok.Builder; import lombok.Data; import lombok.NoArgsConstructor; import org.dromara.visor.common.security.UpdatePasswordAction; +import org.dromara.visor.framework.web.core.annotation.ParamDecrypt; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; @@ -56,14 +57,16 @@ public class HostKeyUpdateRequest implements UpdatePasswordAction { @Schema(description = "名称") private String name; + @ParamDecrypt @Schema(description = "公钥文本") private String publicKey; @NotBlank + @ParamDecrypt @Schema(description = "私钥文本") private String privateKey; - @Size(max = 512) + @ParamDecrypt @Schema(description = "密码") private String password; diff --git a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/handler/host/config/strategy/HostSshConfigStrategy.java b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/handler/host/config/strategy/HostSshConfigStrategy.java index da8536dd..0fd5da54 100644 --- a/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/handler/host/config/strategy/HostSshConfigStrategy.java +++ b/orion-visor-modules/orion-visor-module-asset/orion-visor-module-asset-service/src/main/java/org/dromara/visor/module/asset/handler/host/config/strategy/HostSshConfigStrategy.java @@ -24,12 +24,12 @@ package org.dromara.visor.module.asset.handler.host.config.strategy; import cn.orionsec.kit.lang.utils.Booleans; import cn.orionsec.kit.lang.utils.Charsets; -import cn.orionsec.kit.lang.utils.Exceptions; import cn.orionsec.kit.lang.utils.Strings; import org.dromara.visor.common.constant.Const; import org.dromara.visor.common.constant.ErrorMessage; import org.dromara.visor.common.handler.data.strategy.AbstractGenericsDataStrategy; -import org.dromara.visor.common.security.PasswordModifier; +import org.dromara.visor.common.utils.AesEncryptUtils; +import org.dromara.visor.common.utils.RsaEncryptUtils; import org.dromara.visor.common.utils.Valid; import org.dromara.visor.module.asset.dao.HostIdentityDAO; import org.dromara.visor.module.asset.dao.HostKeyDAO; @@ -126,16 +126,18 @@ public class HostSshConfigStrategy extends AbstractGenericsDataStrategy('/infra/system-setting/app-info'); } +/** + * 获取系统聚合设置 + */ +export function getSystemAggregateSetting() { + return axios.get('/infra/system-setting/setting'); +} + /** * 获取应用最新版本信息 */ @@ -75,22 +98,29 @@ export function getAppLatestRelease() { } /** - * 更新系统设置 + * 生成密钥对 + */ +export function generatorKeypair() { + return axios.get('/infra/system-setting/generator-keypair'); +} + +/** + * 更新系统设置-单个 */ export function updateSystemSetting(request: SystemSettingUpdateRequest) { return axios.put('/infra/system-setting/update', request); } /** - * 更新部分系统设置 + * 更新系统设置-多个 */ -export function updatePartialSystemSetting(request: SystemSettingUpdateRequest) { - return axios.put('/infra/system-setting/update-partial', request); +export function updateSystemSettingBatch(request: SystemSettingUpdateRequest) { + return axios.put('/infra/system-setting/update-batch', request); } /** * 查询系统设置 */ export function getSystemSetting(type: SystemSettingType) { - return axios.get('/infra/system-setting/setting', { params: { type } }); + return axios.get('/infra/system-setting/get', { params: { type } }); } diff --git a/orion-visor-ui/src/store/modules/cache/index.ts b/orion-visor-ui/src/store/modules/cache/index.ts index 9f65b5af..caadb39a 100644 --- a/orion-visor-ui/src/store/modules/cache/index.ts +++ b/orion-visor-ui/src/store/modules/cache/index.ts @@ -2,8 +2,6 @@ import type { CacheState, CacheType } from './types'; import type { AxiosResponse } from 'axios'; import type { TagType } from '@/api/meta/tag'; import { getTagList } from '@/api/meta/tag'; -import type { SystemSettingType } from '@/api/system/setting'; -import { getSystemSetting } from '@/api/system/setting'; import type { HostType } from '@/api/asset/host'; import { getHostList } from '@/api/asset/host'; import type { PreferenceType } from '@/api/user/preference'; @@ -23,6 +21,7 @@ import { getExecJobList } from '@/api/exec/exec-job'; import { getPathBookmarkGroupList } from '@/api/asset/path-bookmark-group'; import { getCommandSnippetList } from '@/api/asset/command-snippet'; import { getPathBookmarkList } from '@/api/asset/path-bookmark'; +import { getSystemAggregateSetting } from '@/api/system/setting'; export default defineStore('cache', { state: (): CacheState => ({}), @@ -170,8 +169,8 @@ export default defineStore('cache', { }, // 加载系统配置 - async loadSystemSetting(type: SystemSettingType, force = false) { - return await this.load(`system_setting_${type}`, () => getSystemSetting(type), undefined, force, {}); + async loadSystemSetting(force = false) { + return await this.load(`system_setting`, getSystemAggregateSetting, undefined, force, {}); }, } diff --git a/orion-visor-ui/src/store/modules/cache/types.ts b/orion-visor-ui/src/store/modules/cache/types.ts index 9c25cb49..c42a1948 100644 --- a/orion-visor-ui/src/store/modules/cache/types.ts +++ b/orion-visor-ui/src/store/modules/cache/types.ts @@ -6,7 +6,7 @@ export type CacheType = 'users' | 'menus' | 'roles' | 'authorizedHostKeys' | 'authorizedHostIdentities' | 'commandSnippetGroups' | 'pathBookmarkGroups' | 'commandSnippets' | 'pathBookmarks' - | '*_Tags' | 'preference_*' | 'system_setting_*' | 'footer_setting' + | '*_Tags' | 'preference_*' | 'system_setting' | string export interface CacheState { diff --git a/orion-visor-ui/src/utils/rsa.ts b/orion-visor-ui/src/utils/rsa.ts new file mode 100644 index 00000000..98befd05 --- /dev/null +++ b/orion-visor-ui/src/utils/rsa.ts @@ -0,0 +1,22 @@ +import { JSEncrypt } from 'jsencrypt'; +import { useCacheStore } from '@/store'; +import { Message } from '@arco-design/web-vue'; + +// 加密 +export const encrypt = async (data: string | undefined): Promise => { + // 为空直接返回 + if (!data) { + return data; + } + // 获取公钥 + const { encrypt } = await useCacheStore().loadSystemSetting(); + const encryptor = new JSEncrypt(); + encryptor.setPublicKey(encrypt?.publicKey); + // 加密 + const value = encryptor.encrypt(data); + if (value === false) { + Message.error('数据加密失败'); + throw new Error('数据加密失败'); + } + return value; +}; diff --git a/orion-visor-ui/src/views/asset/grant/components/host-group-grant.vue b/orion-visor-ui/src/views/asset/grant/components/host-group-grant.vue index a8cf7657..7fb25439 100644 --- a/orion-visor-ui/src/views/asset/grant/components/host-group-grant.vue +++ b/orion-visor-ui/src/views/asset/grant/components/host-group-grant.vue @@ -33,8 +33,8 @@