我有兴趣在成功验证后从 Credentials 对象中清除纯文本密码,并且想知道执行此操作的最佳方法是什么?看起来它可能会在 ProviderManager 对象上设置eraseCredentialsAfterAuthentication 属性,但如何在 Spring Security 插件中执行此操作并不明显。
最佳答案
我发现设置此属性的唯一方法是在 Bootstrap 期间执行此操作。在 BootStrap.groovy 的 init 闭包中添加以下两行:
def ctx = org.codehaus.groovy.grails.web.context.ServletContextHolder.servletContext.getAttribute(org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes.APPLICATION_CONTEXT);
ctx.authenticationManager.setEraseCredentialsAfterAuthentication(true)
我已经在 Grails 1.3.7 上对此进行了测试。
关于Grails Spring Security 1.2.1和eraseCredentialsAfterAuthentication,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7329852/