spring-security
WebSecurityConfigurerAdapter 없이 설정 방법
張's blog
2022. 8. 6. 17:33
- WebSecurityConfigurerAdapter deprecated
https://spring.io/blog/2022/02/21/spring-security-without-the-websecurityconfigureradapter
https://www.appsdeveloperblog.com/migrating-from-deprecated-websecurityconfigureradapter/
https://stackoverflow.com/questions/71281032/spring-security-exposing-authenticationmanager-without-websecurityconfigureradap
@Bean(BeanIds.AUTHENTICATION_MANAGER)
public AuthenticationManager authenticationManager(AuthenticationConfiguration authenticationConfiguration) throws Exception {
return authenticationConfiguration.getAuthenticationManager();
}
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// AuthenticationProvider
http.authenticationProvider(authenticationProvider);
// AuthenticationManager
AuthenticationManager authManager = authenticationManager(http.getSharedObject(AuthenticationConfiguration.class));
UsernamePasswordAuthenticationFilter authFilter = new UsernamePasswordAuthenticationFilter(authManager);
http.addFilterAt(authFilter, UsernamePasswordAuthenticationFilter.class);
}