Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge #86

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docker/adminer/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/bin/bash
version=2.3.0
version=2.3.1
docker build -t orion-visor-adminer:${version} .
docker tag orion-visor-adminer:${version} registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-adminer:${version}
docker tag orion-visor-adminer:${version} registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-adminer:latest
2 changes: 1 addition & 1 deletion docker/mysql/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/bin/bash
version=2.3.0
version=2.3.1
cp -r ../../sql ./sql
docker build -t orion-visor-mysql:${version} .
rm -rf ./sql
Expand Down
2 changes: 1 addition & 1 deletion docker/push.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/bin/bash
version=2.3.0
version=2.3.1
docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-adminer:${version}
docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-mysql:${version}
docker push registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:${version}
Expand Down
2 changes: 1 addition & 1 deletion docker/redis/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/bin/bash
version=2.3.0
version=2.3.1
docker build -t orion-visor-redis:${version} .
docker tag orion-visor-redis:${version} registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:${version}
docker tag orion-visor-redis:${version} registry.cn-hangzhou.aliyuncs.com/orionsec/orion-visor-redis:latest
2 changes: 1 addition & 1 deletion docker/service/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#/bin/bash
version=2.3.0
version=2.3.1
mv ../../orion-visor-launch/target/orion-visor-launch.jar ./orion-visor-launch.jar
mv ../../orion-visor-ui/dist ./dist
docker build --no-cache -t orion-visor-service:${version} .
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public interface AppConst extends OrionConst {
/**
* 同 ${orion.version} 迭代时候需要手动更改
*/
String VERSION = "2.3.0";
String VERSION = "2.3.1";

/**
* 同 ${spring.application.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,13 @@
package org.dromara.visor.common.interfaces;

/**
* rsa 加密器
* rsa 解密器
*
* @author Jiahang Li
* @version 1.0.0
* @since 2025/1/5 20:58
*/
public interface RsaEncryptor {

/**
* 加密
*
* @param value value
* @return value
*/
String encrypt(String value);
public interface RsaDecryptor {

/**
* 解密
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,20 @@
package org.dromara.visor.common.utils;

import cn.orionsec.kit.lang.utils.Exceptions;
import org.dromara.visor.common.interfaces.RsaEncryptor;
import org.dromara.visor.common.interfaces.RsaDecryptor;

/**
* rsa 加密工具类
* rsa 参数解密工具类
*
* @author Jiahang Li
* @version 1.0.0
* @since 2025/1/5 21:13
*/
public class RsaEncryptUtils {
public class RsaParamDecryptUtils {

private static RsaEncryptor delegate;
private static RsaDecryptor delegate;

private RsaEncryptUtils() {
}

/**
* 加密
*
* @param value value
* @return value
*/
public static String encrypt(String value) {
return delegate.encrypt(value);
private RsaParamDecryptUtils() {
}

/**
Expand All @@ -59,12 +49,12 @@ public static String decrypt(String value) {
return delegate.decrypt(value);
}

public static void setDelegate(RsaEncryptor delegate) {
if (RsaEncryptUtils.delegate != null) {
public static void setDelegate(RsaDecryptor delegate) {
if (RsaParamDecryptUtils.delegate != null) {
// unmodified
throw Exceptions.state();
}
RsaEncryptUtils.delegate = delegate;
RsaParamDecryptUtils.delegate = delegate;
}

}
2 changes: 1 addition & 1 deletion orion-visor-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<url>https://github.com/dromara/orion-visor</url>

<properties>
<revision>2.3.0</revision>
<revision>2.3.1</revision>
<spring.boot.version>2.7.17</spring.boot.version>
<spring.boot.admin.version>2.7.15</spring.boot.admin.version>
<flatten.maven.plugin.version>1.5.0</flatten.maven.plugin.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
import org.dromara.visor.common.config.ConfigStore;
import org.dromara.visor.common.constant.AutoConfigureOrderConst;
import org.dromara.visor.common.interfaces.AesEncryptor;
import org.dromara.visor.common.interfaces.RsaEncryptor;
import org.dromara.visor.common.interfaces.RsaDecryptor;
import org.dromara.visor.common.utils.AesEncryptUtils;
import org.dromara.visor.common.utils.RsaEncryptUtils;
import org.dromara.visor.common.utils.RsaParamDecryptUtils;
import org.dromara.visor.framework.encrypt.configuration.config.AesEncryptConfig;
import org.dromara.visor.framework.encrypt.core.impl.AesEncryptorImpl;
import org.dromara.visor.framework.encrypt.core.impl.RsaEncryptorImpl;
import org.dromara.visor.framework.encrypt.core.impl.RsaDecryptorImpl;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand Down Expand Up @@ -63,15 +63,15 @@ public AesEncryptor aesEncryptor(AesEncryptConfig config) {

/**
* @param configStore configStore
* @return rsa 加密器
* @return rsa 参数解密器
*/
@Bean
public RsaEncryptor rsaEncryptor(ConfigStore configStore) {
// 加密器
RsaEncryptor encryptor = new RsaEncryptorImpl(configStore);
public RsaDecryptor rsaParamDecryptor(ConfigStore configStore) {
// 解密器
RsaDecryptor decryptor = new RsaDecryptorImpl(configStore);
// 设置工具类
RsaEncryptUtils.setDelegate(encryptor);
return encryptor;
RsaParamDecryptUtils.setDelegate(decryptor);
return decryptor;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@
import org.dromara.visor.common.config.ConfigRef;
import org.dromara.visor.common.config.ConfigStore;
import org.dromara.visor.common.constant.ConfigKeys;
import org.dromara.visor.common.interfaces.RsaEncryptor;
import org.dromara.visor.common.interfaces.RsaDecryptor;

import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.util.Arrays;
import java.util.stream.Collectors;

/**
* rsa 加密器
Expand All @@ -38,25 +39,21 @@
* @version 1.0.0
* @since 2025/1/7 11:32
*/
public class RsaEncryptorImpl implements RsaEncryptor {
public class RsaDecryptorImpl implements RsaDecryptor {

private final ConfigRef<RSAPublicKey> publicKey;
private static final String SPLIT = "\\|";

private final ConfigRef<RSAPrivateKey> privateKey;

public RsaEncryptorImpl(ConfigStore configStore) {
this.publicKey = configStore.ref(ConfigKeys.ENCRYPT_PUBLIC_KEY, RSA::getPublicKey);
public RsaDecryptorImpl(ConfigStore configStore) {
this.privateKey = configStore.ref(ConfigKeys.ENCRYPT_PRIVATE_KEY, RSA::getPrivateKey);
}

@Override
public String encrypt(String value) {
return RSA.encrypt(value, publicKey.value);
}

@Override
public String decrypt(String value) {
return RSA.decrypt(value, privateKey.value);
return Arrays.stream(value.split(SPLIT))
.map(s -> RSA.decrypt(s, privateKey.value))
.collect(Collectors.joining());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonNode;
import org.dromara.visor.common.constant.ErrorMessage;
import org.dromara.visor.common.utils.RsaEncryptUtils;
import org.dromara.visor.common.utils.RsaParamDecryptUtils;
import org.dromara.visor.common.utils.Valid;

import java.io.IOException;
Expand All @@ -51,7 +51,7 @@ public String deserialize(JsonParser p, DeserializationContext ctx) throws IOExc
return value;
}
// 解密参数
String decrypt = RsaEncryptUtils.decrypt(value);
String decrypt = RsaParamDecryptUtils.decrypt(value);
return Valid.notNull(decrypt, ErrorMessage.DECRYPT_ERROR);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@
*/
public class ReplaceVersion {

private static final String TARGET_VERSION = "2.2.3";
private static final String TARGET_VERSION = "2.3.0";

private static final String REPLACE_VERSION = "2.3.0";
private static final String REPLACE_VERSION = "2.3.1";

private static final String PATH = new File("").getAbsolutePath();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.dromara.visor.common.constant.ErrorMessage;
import org.dromara.visor.common.handler.data.strategy.AbstractGenericsDataStrategy;
import org.dromara.visor.common.utils.AesEncryptUtils;
import org.dromara.visor.common.utils.RsaEncryptUtils;
import org.dromara.visor.common.utils.RsaParamDecryptUtils;
import org.dromara.visor.common.utils.Valid;
import org.dromara.visor.module.asset.dao.HostIdentityDAO;
import org.dromara.visor.module.asset.dao.HostKeyDAO;
Expand Down Expand Up @@ -134,7 +134,7 @@ private void checkEncryptPassword(HostSshConfigModel before, HostSshConfigModel
// 检查新密码
String newPassword = Valid.notBlank(after.getPassword(), ErrorMessage.PASSWORD_MISSING);
// 解密密码
newPassword = RsaEncryptUtils.decrypt(newPassword);
newPassword = RsaParamDecryptUtils.decrypt(newPassword);
Valid.notBlank(newPassword, ErrorMessage.DECRYPT_ERROR);
// 设置密码
after.setPassword(AesEncryptUtils.encryptAsString(newPassword));
Expand Down
2 changes: 1 addition & 1 deletion orion-visor-ui/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ VITE_API_BASE_URL=http://127.0.0.1:9200/orion-visor/api
# websocket 路径
VITE_WS_BASE_URL=ws://127.0.0.1:9200/orion-visor/keep-alive
# 版本号
VITE_APP_VERSION=2.3.0
VITE_APP_VERSION=2.3.1
2 changes: 1 addition & 1 deletion orion-visor-ui/.env.production
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ VITE_API_BASE_URL=/orion-visor/api
# websocket 路径
VITE_WS_BASE_URL=/orion-visor/keep-alive
# 版本号
VITE_APP_VERSION=2.3.0
VITE_APP_VERSION=2.3.1
2 changes: 1 addition & 1 deletion orion-visor-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "orion-visor-ui",
"description": "Orion Visor UI",
"version": "2.3.0",
"version": "2.3.1",
"private": true,
"author": "Jiahang Li",
"license": "Apache 2.0",
Expand Down
33 changes: 27 additions & 6 deletions orion-visor-ui/src/utils/rsa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,42 @@ import { JSEncrypt } from 'jsencrypt';
import { useCacheStore } from '@/store';
import { Message } from '@arco-design/web-vue';

// 分块大小
const BLOCK_SIZE = 100;

// 加密
export const encrypt = async (data: string | undefined): Promise<string | undefined> => {
// 为空直接返回
if (!data) {
return data;
}
// 获取公钥
const { encrypt } = await useCacheStore().loadSystemSetting();
const publicKey = (await useCacheStore().loadSystemSetting()).encrypt?.publicKey;
const encryptor = new JSEncrypt();
encryptor.setPublicKey(encrypt?.publicKey);
// 加密
const value = encryptor.encrypt(data);
if (value === false) {
encryptor.setPublicKey(publicKey);

try {
// 分块加密
const chunks = splitString(data);
const encryptedChunks = chunks.map(chunk => {
const encrypted = encryptor.encrypt(chunk);
if (encrypted === false) {
throw new Error();
}
return encrypted;
});
return encryptedChunks.join('|');
} catch (error) {
Message.error('数据加密失败');
throw new Error('数据加密失败');
}
return value;
};

// 分割字符串
const splitString = (str: string): string[] => {
const chunks: string[] = [];
for (let i = 0; i < str.length; i += BLOCK_SIZE) {
chunks.push(str.slice(i, i + BLOCK_SIZE));
}
return chunks;
};
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</modules>

<properties>
<revision>2.3.0</revision>
<revision>2.3.1</revision>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<maven.surefire.plugin.version>3.0.0-M5</maven.surefire.plugin.version>
Expand Down
Loading