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