mirror of
https://github.com/continew-org/continew-starter.git
synced 2025-10-14 02:57:08 +08:00
feat(encrypt/password-encoder): 新增密码编码器模块(经过考量重新拆分出来)
This commit is contained in:
@@ -164,6 +164,7 @@ continew-starter
|
||||
│ ├─ continew-starter-encrypt-core(核心模块)
|
||||
│ ├─ continew-starter-encrypt-field(字段加密)
|
||||
│ └─ continew-starter-encrypt-api(API 加密)
|
||||
│ └─ continew-starter-encrypt-password-encoder(密码编码器)
|
||||
├─ continew-starter-security(安全模块)
|
||||
│ ├─ continew-starter-security-mask(脱敏:JSON 数据脱敏)
|
||||
│ ├─ continew-starter-security-xss(XSS 过滤)
|
||||
|
@@ -116,6 +116,12 @@
|
||||
<artifactId>continew-starter-encrypt-api</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 加密模块 - 密码编码器 -->
|
||||
<dependency>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-encrypt-password-encoder</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<!-- 加密模块 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
|
@@ -27,11 +27,5 @@
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-crypto</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Security 附带的一个密码加密库 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-crypto</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@@ -55,12 +55,7 @@ public enum Algorithm {
|
||||
/**
|
||||
* Base64
|
||||
*/
|
||||
BASE64(Base64Encryptor.class),
|
||||
|
||||
/**
|
||||
* 密码编码器,支持算法:BCrypt、SCRYPT、PBKDF2、ARGON2
|
||||
*/
|
||||
PASSWORD_ENCODER(PasswordEncoderEncryptor.class);
|
||||
BASE64(Base64Encryptor.class);
|
||||
|
||||
/**
|
||||
* 加密/解密处理器
|
||||
|
@@ -1 +0,0 @@
|
||||
top.continew.starter.encrypt.autoconfigure.PasswordEncoderAutoConfiguration
|
@@ -17,9 +17,7 @@
|
||||
package top.continew.starter.encrypt.field.autoconfigure;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.NestedConfigurationProperty;
|
||||
import top.continew.starter.core.constant.PropertiesConstants;
|
||||
import top.continew.starter.encrypt.autoconfigure.PasswordEncoderProperties;
|
||||
import top.continew.starter.encrypt.enums.Algorithm;
|
||||
|
||||
/**
|
||||
@@ -57,12 +55,6 @@ public class FieldEncryptProperties {
|
||||
*/
|
||||
private String privateKey;
|
||||
|
||||
/**
|
||||
* 密码编码器配置
|
||||
*/
|
||||
@NestedConfigurationProperty
|
||||
private PasswordEncoderProperties passwordEncoder;
|
||||
|
||||
public Boolean getEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
@@ -102,12 +94,4 @@ public class FieldEncryptProperties {
|
||||
public void setPrivateKey(String privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
public PasswordEncoderProperties getPasswordEncoder() {
|
||||
return passwordEncoder;
|
||||
}
|
||||
|
||||
public void setPasswordEncoder(PasswordEncoderProperties passwordEncoder) {
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-encrypt</artifactId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>continew-starter-encrypt-password-encoder</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>ContiNew Starter 加密模块 - 密码编码器</description>
|
||||
|
||||
<dependencies>
|
||||
<!-- 加密模块 - 核心模块 -->
|
||||
<dependency>
|
||||
<groupId>top.continew.starter</groupId>
|
||||
<artifactId>continew-starter-encrypt-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Spring Security 附带的一个密码加密库 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-crypto</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.encrypt.autoconfigure;
|
||||
package top.continew.starter.encrypt.password.encoder.autoconfigure;
|
||||
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.slf4j.Logger;
|
||||
@@ -29,8 +29,8 @@ import org.springframework.security.crypto.password.DelegatingPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import top.continew.starter.core.constant.PropertiesConstants;
|
||||
import top.continew.starter.core.util.validation.CheckUtils;
|
||||
import top.continew.starter.encrypt.enums.PasswordEncoderAlgorithm;
|
||||
import top.continew.starter.encrypt.util.PasswordEncoderUtil;
|
||||
import top.continew.starter.encrypt.password.encoder.enums.PasswordEncoderAlgorithm;
|
||||
import top.continew.starter.encrypt.password.encoder.util.PasswordEncoderUtil;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
@@ -14,9 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.encrypt.autoconfigure;
|
||||
package top.continew.starter.encrypt.password.encoder.autoconfigure;
|
||||
|
||||
import top.continew.starter.encrypt.enums.PasswordEncoderAlgorithm;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import top.continew.starter.core.constant.PropertiesConstants;
|
||||
import top.continew.starter.encrypt.password.encoder.enums.PasswordEncoderAlgorithm;
|
||||
|
||||
/**
|
||||
* 密码编码器配置属性
|
||||
@@ -25,6 +27,7 @@ import top.continew.starter.encrypt.enums.PasswordEncoderAlgorithm;
|
||||
* @author Charles7c
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@ConfigurationProperties(PropertiesConstants.ENCRYPT_PASSWORD_ENCODER)
|
||||
public class PasswordEncoderProperties {
|
||||
|
||||
/**
|
@@ -14,13 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.encrypt.encryptor;
|
||||
package top.continew.starter.encrypt.password.encoder.encryptor;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import top.continew.starter.core.util.SpringUtils;
|
||||
import top.continew.starter.encrypt.autoconfigure.PasswordEncoderProperties;
|
||||
import top.continew.starter.encrypt.context.CryptoContext;
|
||||
import top.continew.starter.encrypt.encryptor.AbstractEncryptor;
|
||||
import top.continew.starter.encrypt.password.encoder.autoconfigure.PasswordEncoderProperties;
|
||||
|
||||
/**
|
||||
* 密码编码器加密器
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.encrypt.enums;
|
||||
package top.continew.starter.encrypt.password.encoder.enums;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.encrypt.exception;
|
||||
package top.continew.starter.encrypt.password.encoder.exception;
|
||||
|
||||
import top.continew.starter.core.exception.BaseException;
|
||||
|
@@ -14,15 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package top.continew.starter.encrypt.util;
|
||||
package top.continew.starter.encrypt.password.encoder.util;
|
||||
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.argon2.Argon2PasswordEncoder;
|
||||
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
|
||||
import org.springframework.security.crypto.scrypt.SCryptPasswordEncoder;
|
||||
import top.continew.starter.encrypt.enums.PasswordEncoderAlgorithm;
|
||||
import top.continew.starter.encrypt.exception.PasswordEncodeException;
|
||||
import top.continew.starter.encrypt.password.encoder.exception.PasswordEncodeException;
|
||||
import top.continew.starter.encrypt.password.encoder.enums.PasswordEncoderAlgorithm;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
@@ -0,0 +1 @@
|
||||
top.continew.starter.encrypt.password.encoder.autoconfigure.PasswordEncoderAutoConfiguration
|
@@ -19,5 +19,6 @@
|
||||
<module>continew-starter-encrypt-core</module>
|
||||
<module>continew-starter-encrypt-field</module>
|
||||
<module>continew-starter-encrypt-api</module>
|
||||
<module>continew-starter-encrypt-password-encoder</module>
|
||||
</modules>
|
||||
</project>
|
Reference in New Issue
Block a user