Spring security plugin not throwing events

2k Views Asked by At

I am in the process of migrating to spring security plugin from acegi plugin.Currently working on grails environment. I am facing a weird issue as my authentication success event and authentication bad credentials event does not throw at all.I added println statements in the callback in config.groovy and also through listeners.However i can catch events like InteractiveAuthenticationSuccessEvent. Please do reply if you have gone through the same issue

2

There are 2 best solutions below

4
Burt Beckwith On

As mentioned in Chapter 5 of the user guide you need to enable events with "useSecurityEventListener" and configure one or more callback closures, e.g.:

grails.plugins.springsecurity.useSecurityEventListener = true

grails.plugins.springsecurity.onInteractiveAuthenticationSuccessEvent = { e, appCtx ->
   println "onInteractiveAuthenticationSuccessEvent: $e"
}

grails.plugins.springsecurity.onAbstractAuthenticationFailureEvent = { e, appCtx ->
   println "onAbstractAuthenticationFailureEvent: $e"
}

grails.plugins.springsecurity.onAuthenticationSuccessEvent = { e, appCtx ->
   println "onAuthenticationSuccessEvent: $e"
}

grails.plugins.springsecurity.onAuthenticationSwitchUserEvent = { e, appCtx ->
   println "onAuthenticationSwitchUserEvent: $e"
}
0
Kalarani On

The provider manager uses the Null event publisher by default. We can inject the default authentication event publisher in resources.groovy.

defaultEventPublisher(DefaultAuthenticationEventPublisher) /** authenticationManager */ authenticationManager(ProviderManager) { authenticationEventPublisher = ref('defaultEventPublisher') providers = listOfProviders }