- 문제 상황
- Spring Boot로 OAuth2 인가서버를 만드는 과정에서 문제 발생
- OAuth2AuthorizationServerConfiguration 설정에서 문제
- applyDefaultSecurity(http) 정적 메소드가 deprecated 되었다
- 1.4 버전 이후로 deprecated
// Deprecated
OAuth2AuthorizationServerConfiguration.applyDefaultSecurity(http);
- 해결 방법
- OAuth2AuthorizationServerConfigurer 직접 적용: applyDefaultSecurity 대신 OAuth2AuthorizationServerConfigurer를 HttpSecurity 객체에 직접 적용
@Bean
public SecurityFilterChain authorizationServerSecurityFilterChain(HttpSecurity http) throws Exception {
// 커스텀 없는 기본적인 구조
http.with(OAuth2AuthorizationServerConfigurer.authorizationServer(), Customizer.withDefaults());
return http.build();
}
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
OAuth2AuthorizationServerConfigurer<HttpSecurity> authorizationServerConfigurer =
new OAuth2AuthorizationServerConfigurer<>();
http.apply(authorizationServerConfigurer);
http
.csrf(csrf -> csrf.disable()) // 추가 설정 예시
.authorizeRequests(authorize -> authorize
.anyRequest().authenticated()
)
.formLogin();
return http.build();
}
댓글