Skip to content

Commit

Permalink
Merge branch 'feature/1.0.0' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
fuhouyu committed Sep 7, 2024
2 parents ac62e82 + 179b70b commit 433eaf8
Show file tree
Hide file tree
Showing 16 changed files with 335 additions and 204 deletions.
12 changes: 0 additions & 12 deletions base-framework-cache-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,6 @@
<description>基础框架缓存starter</description>
<packaging>jar</packaging>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fuhouyu</groupId>
<artifactId>base-framework-dependencies</artifactId>
<version>${revision}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down
12 changes: 0 additions & 12 deletions base-framework-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@
<name>Base Framework Common</name>
<description>公共组件,定义常用的常量、枚举等</description>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fuhouyu</groupId>
<artifactId>base-framework-dependencies</artifactId>
<version>${revision}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
Expand Down
12 changes: 0 additions & 12 deletions base-framework-context/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@
<name>Base Framework Context</name>
<description>上下文组件,主要定义相应的上下文组件,如用户上下文</description>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fuhouyu</groupId>
<artifactId>base-framework-dependencies</artifactId>
<version>${revision}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>junit</groupId>
Expand Down
47 changes: 1 addition & 46 deletions base-framework-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,54 +12,9 @@

<artifactId>base-framework-dependencies</artifactId>
<name>Base Framework Dependencies</name>
<description>基础框架内部模块版本号定义</description>
<description>基础框架依赖定义</description>
<packaging>pom</packaging>


<dependencyManagement>
<dependencies>
<!--内部依赖-->
<dependency>
<groupId>com.fuhouyu</groupId>
<artifactId>base-framework-context</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.fuhouyu</groupId>
<artifactId>base-framework-cache-starter</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.fuhouyu</groupId>
<artifactId>base-framework-log-starter</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.fuhouyu</groupId>
<artifactId>base-framework-common</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.fuhouyu</groupId>
<artifactId>base-framework-security-starter</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.fuhouyu</groupId>
<artifactId>base-framework-web-starter</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.fuhouyu</groupId>
<artifactId>base-framework-reseource-starter</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>com.fuhouyu</groupId>
<artifactId>base-framework-kms-starter</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>

</dependencyManagement>
</project>
12 changes: 0 additions & 12 deletions base-framework-kms-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@
<name>Base Framework Kms Provider</name>
<description>Kms 密钥提供者</description>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fuhouyu</groupId>
<artifactId>base-framework-dependencies</artifactId>
<version>${revision}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.bouncycastle</groupId>
Expand Down
12 changes: 0 additions & 12 deletions base-framework-log-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@
<name>Base Framework Log</name>
<description>日志组件</description>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fuhouyu</groupId>
<artifactId>base-framework-dependencies</artifactId>
<version>${revision}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
Expand Down
11 changes: 0 additions & 11 deletions base-framework-resource-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,6 @@
<name>Base Framework Resource</name>
<description>资源服务组件</description>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fuhouyu</groupId>
<artifactId>base-framework-dependencies</artifactId>
<version>${revision}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fuhouyu</groupId>
Expand Down
22 changes: 8 additions & 14 deletions base-framework-security-starter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,6 @@
<name>Base Framework Auth</name>
<description>基础框架权限认证模块,使用 Spring Security 进行认证</description>


<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.fuhouyu</groupId>
<artifactId>base-framework-dependencies</artifactId>
<version>${revision}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>


<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -69,5 +55,13 @@
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-crypto</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.fuhouyu.framework.security;

import com.fuhouyu.framework.cache.service.CacheService;
import com.fuhouyu.framework.security.core.passwordencoder.PasswordEncoderFactory;
import com.fuhouyu.framework.security.service.DefaultUserAuthServiceImpl;
import com.fuhouyu.framework.security.service.UserAuthService;
import com.fuhouyu.framework.security.token.TokenStore;
Expand All @@ -31,6 +32,7 @@
import org.springframework.security.authentication.ProviderManager;
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.crypto.password.PasswordEncoder;

import java.util.List;

Expand Down Expand Up @@ -76,13 +78,30 @@ public AuthenticationManager authenticationManager(
return new ProviderManager(authenticationProviders);
}

/**
* 创建userAuth bean
*
* @param tokenStore token 存储对象
* @param authenticationManager 认证管理器
* @return userAuth Bean
*/
@Bean
@Primary
@ConditionalOnMissingBean(UserAuthService.class)
public UserAuthService userAuthService(TokenStore tokenStore, AuthenticationManager authenticationManager) {
return new DefaultUserAuthServiceImpl(tokenStore, authenticationManager);
}

/**
* 返回sm3 密码编码器的bean,当passwordEncoder不存在时,则会创建。
*
* @return sm3 密码编码器bean
*/
@Bean
@ConditionalOnMissingBean(PasswordEncoder.class)
public PasswordEncoder passwordEncoder() {
return PasswordEncoderFactory.createDelegatingPasswordEncoder("sm3");
}

/**
* dao层实现
*
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.fuhouyu.framework.security.core.passwordencoder;

import org.springframework.security.crypto.argon2.Argon2PasswordEncoder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.DelegatingPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
import org.springframework.security.crypto.scrypt.SCryptPasswordEncoder;

import java.util.HashMap;
import java.util.Map;

/**
* <p>
* 密码编码器的工厂类
* </p>
*
* @author fuhouyu
* @since 2023/8/30 15:37
*/
public class PasswordEncoderFactory {


private PasswordEncoderFactory() {

}

/**
* 根据encodeId创建一个密码编码器
*
* @param encodingId 编码id
* @return 密码编码器
*/
@SuppressWarnings("deprecation")
public static PasswordEncoder createDelegatingPasswordEncoder(String encodingId) {
Map<String, PasswordEncoder> encoders = new HashMap<>();
encoders.put(encodingId, new BCryptPasswordEncoder());
encoders.put("ldap", new org.springframework.security.crypto.password.LdapShaPasswordEncoder());
encoders.put("MD4", new org.springframework.security.crypto.password.Md4PasswordEncoder());
encoders.put("MD5", new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("MD5"));
encoders.put("noop", org.springframework.security.crypto.password.NoOpPasswordEncoder.getInstance());
encoders.put("pbkdf2", Pbkdf2PasswordEncoder.defaultsForSpringSecurity_v5_5());
encoders.put("pbkdf2@SpringSecurity_v5_8", Pbkdf2PasswordEncoder.defaultsForSpringSecurity_v5_8());
encoders.put("scrypt", SCryptPasswordEncoder.defaultsForSpringSecurity_v4_1());
encoders.put("scrypt@SpringSecurity_v5_8", SCryptPasswordEncoder.defaultsForSpringSecurity_v5_8());
encoders.put("SHA-1", new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("SHA-1"));
encoders.put("SHA-256",
new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("SHA-256"));
encoders.put("sha256", new org.springframework.security.crypto.password.StandardPasswordEncoder());
encoders.put("argon2", Argon2PasswordEncoder.defaultsForSpringSecurity_v5_2());
encoders.put("argon2@SpringSecurity_v5_8", Argon2PasswordEncoder.defaultsForSpringSecurity_v5_8());
encoders.put("sm3", new Sm3PasswordEncoder());
return new DelegatingPasswordEncoder(encodingId, encoders);
}
}
Loading

0 comments on commit 433eaf8

Please sign in to comment.