chore: 修改会话方式类型的配置键值
This commit is contained in:
@@ -22,7 +22,6 @@ import org.springframework.data.redis.core.RedisTemplate;
|
|||||||
import org.springframework.security.authentication.AuthenticationManager;
|
import org.springframework.security.authentication.AuthenticationManager;
|
||||||
import org.springframework.security.authentication.ProviderManager;
|
import org.springframework.security.authentication.ProviderManager;
|
||||||
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
import org.springframework.security.authentication.dao.DaoAuthenticationProvider;
|
||||||
import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration;
|
|
||||||
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
import org.springframework.security.config.annotation.method.configuration.EnableMethodSecurity;
|
||||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||||
@@ -35,9 +34,9 @@ import org.springframework.security.web.SecurityFilterChain;
|
|||||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spring Security 权限配置
|
* Spring Security 安全配置
|
||||||
*
|
*
|
||||||
* @author Ray
|
* @author Ray.Hao
|
||||||
* @since 2023/2/17
|
* @since 2023/2/17
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@@ -46,17 +45,20 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SecurityConfig {
|
public class SecurityConfig {
|
||||||
|
|
||||||
private final MyAuthenticationEntryPoint authenticationEntryPoint;
|
|
||||||
private final MyAccessDeniedHandler accessDeniedHandler;
|
|
||||||
private final RedisTemplate<String, Object> redisTemplate;
|
private final RedisTemplate<String, Object> redisTemplate;
|
||||||
private final CodeGenerator codeGenerator;
|
private final PasswordEncoder passwordEncoder;
|
||||||
private final SecurityProperties securityProperties;
|
|
||||||
private final ConfigService configService;
|
|
||||||
private final JwtTokenService jwtTokenService;
|
private final JwtTokenService jwtTokenService;
|
||||||
private final WxMaService wxMaService;
|
private final WxMaService wxMaService;
|
||||||
private final UserService userService;
|
private final UserService userService;
|
||||||
private final SysUserDetailsService userDetailsService;
|
private final SysUserDetailsService userDetailsService;
|
||||||
private final PasswordEncoder passwordEncoder;
|
|
||||||
|
private final CodeGenerator codeGenerator;
|
||||||
|
private final SecurityProperties securityProperties;
|
||||||
|
private final ConfigService configService;
|
||||||
|
|
||||||
|
private final MyAuthenticationEntryPoint authenticationEntryPoint; // 项目内安全类
|
||||||
|
private final MyAccessDeniedHandler accessDeniedHandler;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
|
||||||
|
|||||||
@@ -16,9 +16,9 @@ import java.util.List;
|
|||||||
public class SecurityProperties {
|
public class SecurityProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 白名单 URL 集合
|
* 会话方式
|
||||||
*/
|
*/
|
||||||
private List<String> ignoreUrls;
|
private SessionProperty session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JWT 配置
|
* JWT 配置
|
||||||
@@ -26,9 +26,17 @@ public class SecurityProperties {
|
|||||||
private JwtProperty jwt;
|
private JwtProperty jwt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 令牌类型 jwt / redis-token
|
* 白名单 URL 集合
|
||||||
*/
|
*/
|
||||||
private String tokenType;
|
private List<String> ignoreUrls;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会话属性
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public static class SessionProperty {
|
||||||
|
private String type;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JWT 配置
|
* JWT 配置
|
||||||
|
|||||||
@@ -33,10 +33,10 @@ import java.util.stream.Collectors;
|
|||||||
/**
|
/**
|
||||||
* JWT 令牌服务实现
|
* JWT 令牌服务实现
|
||||||
*
|
*
|
||||||
* @author Ray
|
* @author Ray.Hao
|
||||||
* @since 2024/11/15
|
* @since 2024/11/15
|
||||||
*/
|
*/
|
||||||
@ConditionalOnProperty(value = "security.token-type", havingValue = "jwt")
|
@ConditionalOnProperty(value = "security.session.type", havingValue = "jwt")
|
||||||
@Service
|
@Service
|
||||||
public class JwtTokenService implements TokenService {
|
public class JwtTokenService implements TokenService {
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,10 @@ import org.springframework.stereotype.Service;
|
|||||||
/**
|
/**
|
||||||
* JWT 令牌服务实现
|
* JWT 令牌服务实现
|
||||||
*
|
*
|
||||||
* @author Ray
|
* @author Ray.Hao
|
||||||
* @since 2024/11/15
|
* @since 2024/11/15
|
||||||
*/
|
*/
|
||||||
@ConditionalOnProperty(value = "security.token-type", havingValue = "redis-token")
|
@ConditionalOnProperty(value = "security.session.type", havingValue = "redis-token")
|
||||||
@Service
|
@Service
|
||||||
public class RedisTokenService implements TokenService {
|
public class RedisTokenService implements TokenService {
|
||||||
|
|
||||||
|
|||||||
@@ -75,8 +75,9 @@ mybatis-plus:
|
|||||||
|
|
||||||
# 安全配置
|
# 安全配置
|
||||||
security:
|
security:
|
||||||
# JWT 认证类型, 支持 jwt、redis-token
|
session:
|
||||||
token-type: jwt
|
# 会话方式,支持 jwt、redis-token
|
||||||
|
type: jwt
|
||||||
jwt:
|
jwt:
|
||||||
# JWT 秘钥
|
# JWT 秘钥
|
||||||
key: SecretKey012345678901234567890123456789012345678901234567890123456789
|
key: SecretKey012345678901234567890123456789012345678901234567890123456789
|
||||||
|
|||||||
@@ -59,8 +59,9 @@ mybatis-plus:
|
|||||||
|
|
||||||
# 安全配置
|
# 安全配置
|
||||||
security:
|
security:
|
||||||
# JWT 认证类型, 支持 jwt、redis-token
|
session:
|
||||||
token-type: jwt
|
# 会话方式,支持 jwt、redis-token
|
||||||
|
type: jwt
|
||||||
# JWT 配置
|
# JWT 配置
|
||||||
jwt:
|
jwt:
|
||||||
# JWT 秘钥
|
# JWT 秘钥
|
||||||
|
|||||||
Reference in New Issue
Block a user