Spring security plugin doesn't throw events

I am trying to upgrade to spring security plugin from acegi plugin. Currently working on the Grails environment. I ran into some kind of strange problem, since my successful authentication event and invalid credential authentication do not throw at all. I added println instructions in the callback to config.groovy, as well as through listeners. However, I can capture events like InteractiveAuthenticationSuccessEvent. Please answer if you went through the same problem.

0
source share
2 answers

As mentioned in chapter 5 of the user guide, you need to enable events using "useSecurityEventListener" and configure one or more callback closures, for example

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"
}
+1
source

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

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

0
source

All Articles