SpringBoot
WebSecurityConfigurerAdapter 대체 SecurityFilterChain
dev22
2023. 7. 7. 20:22
728x90
Deprecated. Use a SecurityFilterChain Bean to configure HttpSecurity or a WebSecurityCustomizer Bean to configure WebSecurity
@RequiredArgsConstructor @EnableWebSecurity //spring security 설정들을 활성화 public class SecurityConfig{ private final CustomOAuth2UserService customOAuth2UserService; @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { http .csrf().disable() .headers().frameOptions().disable() .and() .authorizeRequests() .antMatchers("/", "/css/**", "/images/**", "/js/**", "/h2-console/**").permitAll() .antMatchers("/api/v1/**").hasRole(Role.USER.name()) .anyRequest().authenticated() .and() .logout().logoutSuccessUrl("/") .and() .oauth2Login() .userInfoEndpoint() .userService(customOAuth2UserService); return http.build(); } }