feat: 添加swagger白名单路径

This commit is contained in:
haoxr
2023-02-17 18:49:20 +08:00
parent 63bd7cd769
commit 8c16ec083e

View File

@@ -20,7 +20,10 @@ import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
/**
* Spring Security 权限配置
*
* @author haoxr
* @date 2023/2/17
*/
@Configuration
@EnableWebSecurity
@@ -32,7 +35,6 @@ public class SecurityConfig {
private final MyAccessDeniedHandler myAccessDeniedHandler;
private final JwtTokenManager jwtTokenManager;
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
http
@@ -57,12 +59,20 @@ public class SecurityConfig {
@Bean
public WebSecurityCustomizer webSecurityCustomizer() {
return (web) -> web.ignoring().requestMatchers("/api/v1/auth/login", "/webjars/**", "/doc.html",
"/swagger-resources/**",
"/v3/api-docs/swagger-config",
"/v3/api-docs");
return (web) -> web.ignoring()
.requestMatchers(
"/api/v1/auth/login",
"/webjars/**",
"/doc.html",
"/swagger-resources/**",
"/v3/api-docs/**",
"/swagger-ui/**"
);
}
/**
* 密码编码器
*/
@Bean
public PasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();