Closed sungwon-097 closed 1 year ago
// before public class SecurityConfig extends WebSecurityConfigurerAdapter{ ... @Override protected void configure(HttpSecurity http) throws Exception { ... .addFilter(new JwtAuthenticationFilter(authenticationManager())) ... } } // after public class SecurityConfig { ... @Bean SecurityFilterChain filterChain(HttpSecurity http) throws Exception { ... .apply(new MyCustomDsl()) // 커스텀 필터 등록 ... } public class MyCustomDsl extends AbstractHttpConfigurer<MyCustomDsl, HttpSecurity> { @Override public void configure(HttpSecurity http) throws Exception { AuthenticationManager authenticationManager = http.getSharedObject(AuthenticationManager.class); http .addFilter(corsConfig.corsFilter()) .addFilter(new JwtAuthenticationFilter(authenticationManager)) .addFilter(new JwtAuthorizationFilter(authenticationManager, userRepository)); } } }
https://github.com/sungwon-097/Spring_Security/blob/main/security1/src/main/java/com/cos/security1/config/SecurityConfig.java