WEBBOOK CHAPTER

Spring Security 6, 인증에서 운영까지: 38장. Boot 2에서 3으로, 3에서 4로 이동 경로를 만든다

38장. Boot 2에서 3으로, 3에서 4로 이동 경로를 만든다

Boot 2에서 3은 Java 기준, javax.*에서 jakarta.*, Spring Security 6 DSL과 method security 변경이 핵심이다. WebSecurityConfigurerAdapter 상속 대신 bean 기반 SecurityFilterChain, @EnableGlobalMethodSecurity 대신 @EnableMethodSecurity를 사용한다. 먼저 최신 Boot 2.7과 Security 5.8 migration 단계를 거치는 전략이 위험을 줄인다.


// 상속 설정 대신 조합 가능한 bean
@Bean
SecurityFilterChain appSecurity(HttpSecurity http) throws Exception {
    return http.authorizeHttpRequests(a -> a.anyRequest().authenticated()).build();
}

3에서 4로 갈 때는 별도 branch에서 compiler, dependency, test fixture를 갱신하고 보안 정책 결과가 같은지 비교한다. “컴파일 성공”보다 401/403, CSRF, cookie, OIDC callback, JWT claim mapping, session 직렬화의 회귀가 중요하다.

버전별 문서를 섞지 않는다. 이 책 코드는 6.5 URL을 링크한다. 업그레이드 branch에서는 대상 major 문서로 전환하고 deprecation을 먼저 제거한다. 두 major를 한 번에 건너뛰며 프레임워크 변경과 제품 정책 변경을 섞지 않는다.