스프링 시큐리티 customprovider 등록 방법

greenTea·2023년 3월 14일

모든 저작권은 Baeldung에 있습니다. All copyrights are in Baeldung.

스프링 시큐리티가 버전업이 되면서 websecurityconfigureradapter가 deprecated되었다. 그에 따라 등록 방법도 달라졌다.
다음은 customprovider 등록 방법이다.

@EnableWebSecurity
public class SecurityConfig {

    @Autowired
    private CustomAuthenticationProvider customProvider;

    @Bean
    public AuthenticationManager authenticationManager (HttpSecurity http) throws Exception {
        AuthenticationManagerBuilder authenticationManagerBuilder = 
            http.getSharedObject(AuthenticationManagerBuilder.class);
        authenticationManagerBuilder.authenticationProvider(customProvider);
        return authenticationManagerBuilder.build();
    }

출처 : Baeldung security

profile
greenTea입니다.

0개의 댓글