mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-09-14 03:01:36 +08:00
refactor: 适配 ContiNew Starter 加密模块(安全模块)
This commit is contained in:
@@ -96,6 +96,12 @@
|
||||
<artifactId>continew-starter-file-excel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- ContiNew Starter 安全模块 - 加密 -->
|
||||
<dependency>
|
||||
<groupId>top.charles7c.continew</groupId>
|
||||
<artifactId>continew-starter-security-crypto</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- ContiNew Starter 安全模块 - 脱敏 -->
|
||||
<dependency>
|
||||
<groupId>top.charles7c.continew</groupId>
|
||||
|
@@ -0,0 +1,29 @@
|
||||
package top.charles7c.continew.admin.common.config.mybatis;
|
||||
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import top.charles7c.continew.starter.security.crypto.encryptor.IEncryptor;
|
||||
|
||||
/**
|
||||
* BCrypt 加/解密处理器(不可逆)
|
||||
*
|
||||
* @author Charles7c
|
||||
* @since 2024/2/8 22:29
|
||||
*/
|
||||
public class BCryptEncryptor implements IEncryptor {
|
||||
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
|
||||
public BCryptEncryptor(PasswordEncoder passwordEncoder) {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encrypt(String plaintext, String password, String publicKey) throws Exception {
|
||||
return passwordEncoder.encode(plaintext);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decrypt(String ciphertext, String password, String privateKey) throws Exception {
|
||||
return ciphertext;
|
||||
}
|
||||
}
|
@@ -21,6 +21,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import top.charles7c.continew.starter.data.mybatis.plus.datapermission.DataPermissionFilter;
|
||||
|
||||
/**
|
||||
@@ -47,4 +48,12 @@ public class MybatisPlusConfiguration {
|
||||
public DataPermissionFilter dataPermissionFilter() {
|
||||
return new DataPermissionFilterImpl();
|
||||
}
|
||||
|
||||
/**
|
||||
* BCrypt 加/解密处理器
|
||||
*/
|
||||
@Bean
|
||||
public BCryptEncryptor bCryptEncryptor(PasswordEncoder passwordEncoder) {
|
||||
return new BCryptEncryptor(passwordEncoder);
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ public class RsaProperties {
|
||||
public static final String PRIVATE_KEY;
|
||||
|
||||
static {
|
||||
PRIVATE_KEY = SpringUtil.getProperty("rsa.privateKey");
|
||||
PRIVATE_KEY = SpringUtil.getProperty("continew-starter.security.crypto.private-key");
|
||||
}
|
||||
|
||||
private RsaProperties() {
|
||||
|
Reference in New Issue
Block a user