问题
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
回答1:
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"
}
回答2:
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
}
来源:https://stackoverflow.com/questions/3130459/spring-security-plugin-not-throwing-events