chore: 修改会话方式类型的配置键值

This commit is contained in:
Ray.Hao
2024-12-04 00:20:46 +08:00
parent a2e9182cb9
commit 3cdca76300
6 changed files with 33 additions and 21 deletions

View File

@@ -22,7 +22,6 @@ import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.ProviderManager;
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.web.builders.HttpSecurity;
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;
/**
* Spring Security 权限配置
* Spring Security 安全配置
*
* @author Ray
* @author Ray.Hao
* @since 2023/2/17
*/
@Configuration
@@ -46,17 +45,20 @@ import org.springframework.security.web.authentication.UsernamePasswordAuthentic
@RequiredArgsConstructor
public class SecurityConfig {
private final MyAuthenticationEntryPoint authenticationEntryPoint;
private final MyAccessDeniedHandler accessDeniedHandler;
private final RedisTemplate<String, Object> redisTemplate;
private final CodeGenerator codeGenerator;
private final SecurityProperties securityProperties;
private final ConfigService configService;
private final PasswordEncoder passwordEncoder;
private final JwtTokenService jwtTokenService;
private final WxMaService wxMaService;
private final UserService userService;
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
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {

View File

@@ -16,9 +16,9 @@ import java.util.List;
public class SecurityProperties {
/**
* 白名单 URL 集合
* 会话方式
*/
private List<String> ignoreUrls;
private SessionProperty session;
/**
* JWT 配置
@@ -26,9 +26,17 @@ public class SecurityProperties {
private JwtProperty jwt;
/**
* 令牌类型 jwt / redis-token
* 白名单 URL 集合
*/
private String tokenType;
private List<String> ignoreUrls;
/**
* 会话属性
*/
@Data
public static class SessionProperty {
private String type;
}
/**
* JWT 配置

View File

@@ -33,10 +33,10 @@ import java.util.stream.Collectors;
/**
* JWT 令牌服务实现
*
* @author Ray
* @author Ray.Hao
* @since 2024/11/15
*/
@ConditionalOnProperty(value = "security.token-type", havingValue = "jwt")
@ConditionalOnProperty(value = "security.session.type", havingValue = "jwt")
@Service
public class JwtTokenService implements TokenService {

View File

@@ -9,10 +9,10 @@ import org.springframework.stereotype.Service;
/**
* JWT 令牌服务实现
*
* @author Ray
* @author Ray.Hao
* @since 2024/11/15
*/
@ConditionalOnProperty(value = "security.token-type", havingValue = "redis-token")
@ConditionalOnProperty(value = "security.session.type", havingValue = "redis-token")
@Service
public class RedisTokenService implements TokenService {