Grails Spring Security 1.2.1和eraseCredentialsAfterAuthentication

标签 grails spring-security password-protection

我有兴趣在成功验证后从 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/

相关文章:

grails - grails 3 应用程序的 gpc 渲染插件出现问题

grails - 如何从 Grails Controller 返回 404/50x 状态代码?

grails - 如何使用Intellij Idea将OpenCv与Grails 3配合使用?

grails - GORM hasMany使用多个列

maven - mvn --encrypt-master-password <password> : Good practice for choosing <password>? 它应该是哪个级别的隐私?

在 Excel 中使用另一个子项的密码的 VBA 代码

spring - 是否有用于 Facelets 的 Spring Security 4.x 标签库

Spring 安全 3.1.3 @EnableWebSecurity

java - 使用 Jaas 配置进行 Kafka 身份验证

hadoop - 如何使用密码保护 Hadoop NameNode 和 JobTracker Web UI?