2010-06-28 41 views
0

我正在從acegi插件遷移到spring security插件的過程中。目前正在使用grails環境。我面臨一個奇怪的問題,因爲我的身份驗證成功事件和身份驗證錯誤憑據事件根本不會拋出。我在config.groovy中的回調中還通過偵聽器添加了println語句。但是我可以捕獲InteractiveAuthenticationSuccessEvent等事件。請不要回應,如果你已經通過了同樣的問題Spring安全插件不會拋出事件

回答

1

瞭如您需要啓用以「useSecurityEventListener」事件,並配置一個或多個回調倒閉,例如user guide的第5章中提到:

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

嘿,我試圖做所有這些,但問題是這些事件從未被調用的。我只能接收onInteractiveAuthenticationSuccessEvent。我瀏覽了Spring源代碼,並在AbstractAuthenticationProcessingFilter類中進行了驗證,他們僅在成功驗證時拋出onInteractiveAuthenticationSuccessEvent,在驗證失敗時他們只是調用失敗處理程序。是否需要添加處理程序而不是偵聽事件?還是我需要注入供應商經理?我沒有添加任何供應商經理,認爲grails的插件會爲我做:( – prabha 2010-06-29 05:19:24

+0

嗯,看起來像Spring Security 2和3之間的事情發生了變化。請在http://jira.codehaus.org/上創建一個問題。瀏覽/ Grails-Spring-Security-Core組件下的GRAILSPLUGINS,我將看到我可以爲下一個版本做些什麼 – 2010-06-29 05:46:09

+0

嘿,感謝您的關注。我們記錄了一個bug,就像你說的http://jira.codehaus .org/browse/GRAILSPLUGINS-2248 – prabha 2010-06-29 09:05:06

0

的提供程序管理器默認使用Null事件發佈程序。我們可以在resources.groovy中注入默認的身份驗證事件發佈者。

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

相關問題