Spring security plugin not throwing events

我们两清 提交于 2020-01-06 06:52:34

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!