You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you extend WebSecurityConfigurerAdapter and override the method protected final void configure(AuthenticationManagerBuilder auth) throws Exception
to set auth.authenticationEventPublisher(defaultAuthenticationEventPublisher);
it doesn't work propertly.
Actual Behavior
When you use the auth.authenticationEventPublisher(defaultAuthenticationEventPublisher) method
to set a custom AuthenticationEventPublisher, the localConfigureAuthenticationBldr (that is an AuthenticationManagerBuilder instance which manage AuthenticationManager buiding) on WebSecurityConfigurerAdapter doesn't build anything (returns null, because it needs AuthenticationProviders to be built).
I have tried a workaround using a "dummy" AuthenticationProvider, but in this case, the structure of built ProviderManagers on WebSecurityConfigurerAdapter is: the one that is built by the localConfigureAuthenticationBldr is set as parent of the other one created by authenticationBuilder.
This causes that we can't set an AuthenticationEventPublisher at the ProviderManager built by authenticationBuilder and consequently, the exceptions thrown by this ProviderManager don't fire any event.
Expected Behavior
Set an AuthenticationEventPublisher on "last" ProviderManager (the one created by authenticationBuilder on WebSecurityConfigurerAdapter), that fire events on this ProviderManager and not in his parent.
Configuration
Version
4.1.0
Sample
@EnableWebSecurity
@Configuration
public abstract class MySecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.x509()
.authenticationUserDetailsService(authenticationUserDetailsService);
}
@Override
protected final void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationEventPublisher(defaultAuthenticationEventPublisher);
}
@Bean
public DefaultAuthenticationEventPublisher defaultAuthenticationEventPublisher() {
return new DefaultAuthenticationEventPublisher();
}
}
@Component
public class MyAppListener implements ApplicationListener<AbstractAuthenticationEvent>, ApplicationContextAware {
private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(MyAppListener .class);
@Override
public void onApplicationEvent(AbstractAuthenticationEvent authEvent) {
LOG.debug("Event: " + authEvent.getClass().getName() + " throwed");
}
}
The text was updated successfully, but these errors were encountered:
mondaka
changed the title
Can't use custom authenticationEventPublisher on button ProviderManager
Can't use custom authenticationEventPublisher on bottom ProviderManager
Jun 25, 2017
mondaka
changed the title
Can't use custom authenticationEventPublisher on bottom ProviderManager
Can't use custom authenticationEventPublisher on last ProviderManager
Sep 6, 2017
Uh oh!
There was an error while loading. Please reload this page.
Summary
When you extend
WebSecurityConfigurerAdapter
and override the methodprotected final void configure(AuthenticationManagerBuilder auth) throws Exception
to set
auth.authenticationEventPublisher(defaultAuthenticationEventPublisher);
it doesn't work propertly.
Actual Behavior
When you use the
auth.authenticationEventPublisher(defaultAuthenticationEventPublisher)
methodto set a custom
AuthenticationEventPublisher
, thelocalConfigureAuthenticationBldr
(that is an AuthenticationManagerBuilder instance which manage AuthenticationManager buiding) onWebSecurityConfigurerAdapter
doesn't build anything (returns null, because it needs AuthenticationProviders to be built).I have tried a workaround using a "dummy" AuthenticationProvider, but in this case, the structure of built
ProviderManager
s onWebSecurityConfigurerAdapter
is: the one that is built by the localConfigureAuthenticationBldr is set as parent of the other one created by authenticationBuilder.This causes that we can't set an
AuthenticationEventPublisher
at theProviderManager
built byauthenticationBuilder
and consequently, the exceptions thrown by thisProviderManager
don't fire any event.Expected Behavior
Set an
AuthenticationEventPublisher
on "last"ProviderManager
(the one created byauthenticationBuilder
onWebSecurityConfigurerAdapter
), that fire events on this ProviderManager and not in his parent.Configuration
Version
4.1.0
Sample
The text was updated successfully, but these errors were encountered: