Skip to content

Commit e414abc

Browse files
committed
feat(encrypt/password-encoder): 新增密码编码器模块(经过考量重新拆分出来)
1 parent 6889578 commit e414abc

File tree

15 files changed

+57
-41
lines changed

15 files changed

+57
-41
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ continew-starter
164164
│ ├─ continew-starter-encrypt-core(核心模块)
165165
│ ├─ continew-starter-encrypt-field(字段加密)
166166
│ └─ continew-starter-encrypt-api(API 加密)
167+
│ └─ continew-starter-encrypt-password-encoder(密码编码器)
167168
├─ continew-starter-security(安全模块)
168169
│ ├─ continew-starter-security-mask(脱敏:JSON 数据脱敏)
169170
│ ├─ continew-starter-security-xss(XSS 过滤)

continew-starter-bom/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@
116116
<artifactId>continew-starter-encrypt-api</artifactId>
117117
<version>${revision}</version>
118118
</dependency>
119+
<!-- 加密模块 - 密码编码器 -->
120+
<dependency>
121+
<groupId>top.continew.starter</groupId>
122+
<artifactId>continew-starter-encrypt-password-encoder</artifactId>
123+
<version>${revision}</version>
124+
</dependency>
119125
<!-- 加密模块 - 核心模块 -->
120126
<dependency>
121127
<groupId>top.continew.starter</groupId>

continew-starter-encrypt/continew-starter-encrypt-core/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,5 @@
2727
<groupId>cn.hutool</groupId>
2828
<artifactId>hutool-crypto</artifactId>
2929
</dependency>
30-
31-
<!-- Spring Security 附带的一个密码加密库 -->
32-
<dependency>
33-
<groupId>org.springframework.security</groupId>
34-
<artifactId>spring-security-crypto</artifactId>
35-
</dependency>
3630
</dependencies>
3731
</project>

continew-starter-encrypt/continew-starter-encrypt-core/src/main/java/top/continew/starter/encrypt/enums/Algorithm.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,7 @@ public enum Algorithm {
5555
/**
5656
* Base64
5757
*/
58-
BASE64(Base64Encryptor.class),
59-
60-
/**
61-
* 密码编码器,支持算法:BCrypt、SCRYPT、PBKDF2、ARGON2
62-
*/
63-
PASSWORD_ENCODER(PasswordEncoderEncryptor.class);
58+
BASE64(Base64Encryptor.class);
6459

6560
/**
6661
* 加密/解密处理器

continew-starter-encrypt/continew-starter-encrypt-core/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

Lines changed: 0 additions & 1 deletion
This file was deleted.

continew-starter-encrypt/continew-starter-encrypt-field/src/main/java/top/continew/starter/encrypt/field/autoconfigure/FieldEncryptProperties.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
package top.continew.starter.encrypt.field.autoconfigure;
1818

1919
import org.springframework.boot.context.properties.ConfigurationProperties;
20-
import org.springframework.boot.context.properties.NestedConfigurationProperty;
2120
import top.continew.starter.core.constant.PropertiesConstants;
22-
import top.continew.starter.encrypt.autoconfigure.PasswordEncoderProperties;
2321
import top.continew.starter.encrypt.enums.Algorithm;
2422

2523
/**
@@ -57,12 +55,6 @@ public class FieldEncryptProperties {
5755
*/
5856
private String privateKey;
5957

60-
/**
61-
* 密码编码器配置
62-
*/
63-
@NestedConfigurationProperty
64-
private PasswordEncoderProperties passwordEncoder;
65-
6658
public Boolean getEnabled() {
6759
return enabled;
6860
}
@@ -102,12 +94,4 @@ public String getPrivateKey() {
10294
public void setPrivateKey(String privateKey) {
10395
this.privateKey = privateKey;
10496
}
105-
106-
public PasswordEncoderProperties getPasswordEncoder() {
107-
return passwordEncoder;
108-
}
109-
110-
public void setPasswordEncoder(PasswordEncoderProperties passwordEncoder) {
111-
this.passwordEncoder = passwordEncoder;
112-
}
11397
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>top.continew.starter</groupId>
8+
<artifactId>continew-starter-encrypt</artifactId>
9+
<version>${revision}</version>
10+
</parent>
11+
12+
<artifactId>continew-starter-encrypt-password-encoder</artifactId>
13+
<packaging>jar</packaging>
14+
15+
<name>${project.artifactId}</name>
16+
<description>ContiNew Starter 加密模块 - 密码编码器</description>
17+
18+
<dependencies>
19+
<!-- 加密模块 - 核心模块 -->
20+
<dependency>
21+
<groupId>top.continew.starter</groupId>
22+
<artifactId>continew-starter-encrypt-core</artifactId>
23+
</dependency>
24+
25+
<!-- Spring Security 附带的一个密码加密库 -->
26+
<dependency>
27+
<groupId>org.springframework.security</groupId>
28+
<artifactId>spring-security-crypto</artifactId>
29+
</dependency>
30+
</dependencies>
31+
</project>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package top.continew.starter.encrypt.autoconfigure;
17+
package top.continew.starter.encrypt.password.encoder.autoconfigure;
1818

1919
import jakarta.annotation.PostConstruct;
2020
import org.slf4j.Logger;
@@ -29,8 +29,8 @@
2929
import org.springframework.security.crypto.password.PasswordEncoder;
3030
import top.continew.starter.core.constant.PropertiesConstants;
3131
import top.continew.starter.core.util.validation.CheckUtils;
32-
import top.continew.starter.encrypt.enums.PasswordEncoderAlgorithm;
33-
import top.continew.starter.encrypt.util.PasswordEncoderUtil;
32+
import top.continew.starter.encrypt.password.encoder.enums.PasswordEncoderAlgorithm;
33+
import top.continew.starter.encrypt.password.encoder.util.PasswordEncoderUtil;
3434

3535
import java.util.HashMap;
3636
import java.util.Map;
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
package top.continew.starter.encrypt.autoconfigure;
17+
package top.continew.starter.encrypt.password.encoder.autoconfigure;
1818

19-
import top.continew.starter.encrypt.enums.PasswordEncoderAlgorithm;
19+
import org.springframework.boot.context.properties.ConfigurationProperties;
20+
import top.continew.starter.core.constant.PropertiesConstants;
21+
import top.continew.starter.encrypt.password.encoder.enums.PasswordEncoderAlgorithm;
2022

2123
/**
2224
* 密码编码器配置属性
@@ -25,6 +27,7 @@
2527
* @author Charles7c
2628
* @since 1.3.0
2729
*/
30+
@ConfigurationProperties(PropertiesConstants.ENCRYPT_PASSWORD_ENCODER)
2831
public class PasswordEncoderProperties {
2932

3033
/**
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
package top.continew.starter.encrypt.encryptor;
17+
package top.continew.starter.encrypt.password.encoder.encryptor;
1818

1919
import cn.hutool.extra.spring.SpringUtil;
2020
import org.springframework.security.crypto.password.PasswordEncoder;
2121
import top.continew.starter.core.util.SpringUtils;
22-
import top.continew.starter.encrypt.autoconfigure.PasswordEncoderProperties;
2322
import top.continew.starter.encrypt.context.CryptoContext;
23+
import top.continew.starter.encrypt.encryptor.AbstractEncryptor;
24+
import top.continew.starter.encrypt.password.encoder.autoconfigure.PasswordEncoderProperties;
2425

2526
/**
2627
* 密码编码器加密器

0 commit comments

Comments
 (0)