Grails Spring Security 1.2.1和橡皮擦身份验证后证书

Grails Spring Security 1.2.1和橡皮擦身份验证后证书,grails,spring-security,password-protection,Grails,Spring Security,Password Protection,我对在成功的身份验证后从凭证对象中清除纯文本密码感兴趣,并且想知道这样做的最佳方法是什么?看起来它可能在ProviderManager对象上设置了橡皮擦身份验证后属性,但在Spring安全插件中如何设置该属性并不明显。我发现设置该属性的唯一方法是在引导过程中进行设置。在init闭包的BootStrap.groovy中添加以下两行: def ctx = org.codehaus.groovy.grails.web.context.ServletContextHolder.servletContex

我对在成功的身份验证后从凭证对象中清除纯文本密码感兴趣,并且想知道这样做的最佳方法是什么?看起来它可能在ProviderManager对象上设置了橡皮擦身份验证后属性,但在Spring安全插件中如何设置该属性并不明显。

我发现设置该属性的唯一方法是在引导过程中进行设置。在init闭包的BootStrap.groovy中添加以下两行:

def ctx = org.codehaus.groovy.grails.web.context.ServletContextHolder.servletContext.getAttribute(org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes.APPLICATION_CONTEXT);

ctx.authenticationManager.setEraseCredentialsAfterAuthentication(true)

我已经在Grails1.3.7上对此进行了测试。

这在最新版本的Spring安全插件(1.2.7)中更容易实现。只需将此设置添加到
Config.groovy

grails.plugins.springsecurity.providerManager.eraseCredentialsAfterAuthentication = true

这个选项似乎是为插件的1.2.2版添加的。

Dave,你看到我下面的答案了吗?我看到了,看起来它会起作用。谢谢。BootStrap支持依赖项注入,因此您只需将
def authenticationManager
添加为一个字段,然后在
init()中调用
authenticationManager.橡皮擦凭据AfterAuthentication=true