[SpringSecurity] Config 변경사항 (SpringBoot 2.7 release Notes)

Ogu·2023년 1월 7일
0

SpringSecurity

목록 보기
1/3

Spring Security without the WebSecurityConfigurerAdapter

In Spring Security 5.4 we introduced the ability to configure HttpSecurity by creating a SecurityFilterChain bean.

💊 기존 방식 : WebSecurityConfigurerAdapter를 class에 상속

Below is an example configuration using the WebSecurityConfigurerAdapter that secures all endpoints with HTTP Basic:

@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

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

}

💊 바뀐 방식 : SecurityFilterChain bean을 등록

Going forward, the recommended way of doing this is registering a SecurityFilterChain bean:

@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

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

}
profile
私はゲームと日本が好きなBackend Developer志望生のOguです🐤🐤

0개의 댓글