WebSecurityConfigurerAdapter (Deprecated) - Spring Security 5.7이상에서 설정.

하쮸·2025년 1월 14일

1. WebSecurityConfigurerAdapter.

  • 스프링 시큐리티에서 기본적인 시큐리티 설정을 하기 위해서는 WebSecurityConfigurerAdapter라는 추상 클래스를 상속받고, configure 메서드를 오버라이드해서 설정했음.

1-1. Deprecated.

  • 스프링 시큐리티 5.7.0-M2부터 WebSecurityConfigurerAdapterdeprecated, 즉 더 이상 사용할 수 없음.

  • Spring Security without the WebSecurityConfigurerAdapter을 참고.

    • 사용자가 컴포넌트 기반의 보안 설정으로 전환 하도록 권장하고 있음.
@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

    @Override
    protected void configure(HttpSecurity http) throws Exception {
        http
            .authorizeHttpRequests((authz) -> authz
                .anyRequest().authenticated()
            )
            .httpBasic(withDefaults());
    }

}
  • 위와 같이 WebSecurityConfigurerAdapter를 사용했던 것을 아래와 같이 변경.
@Configuration
public class SecurityConfiguration {

    @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
        http
            .authorizeHttpRequests((authz) -> authz
                .anyRequest().authenticated()
            )
            .httpBasic(withDefaults());
        return http.build();
    }

}

2. 참고.

profile
Every cloud has a silver lining.

0개의 댓글