@EventListener for AuthenticationSuccessEvent or InteractiveAuthenticationSuccessEvent not fired

前端 未结 2 567
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-13 21:37

I have this listener in the context of Spring:

package listeners;

import java.util.Date;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spr         


        
2条回答
  •  野性不改
    2021-02-13 21:57

    You may need to register the event-publishing infrastructure (eg. by configuring a DefaultAuthenticationEventPublisher).

    @EnableWebSecurity
    class SecurityConfig extends WebSecurityConfigurerAdapter {
    
        ...
    
        @Autowired
        public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
            auth
                .authenticationEventPublisher(authenticationEventPublisher())
                .userDetailsService(userDetailsService)
                .passwordEncoder(passwordEncoder());
        }   
    
        @Bean
        public DefaultAuthenticationEventPublisher authenticationEventPublisher() {
            return new DefaultAuthenticationEventPublisher();
        }
    }
    

提交回复
热议问题