最近,我竭尽全力,试图在spring-security-core grails插件中找到允许特殊密码的方式。
任何人都可以给我看哪里的提示?
澄清:当我安装spring-security-core时,spring-security-ui grails插件并尝试注册提供[\ w \ d] {,8}的简单密码的用户,出现错误:Password must have at least one letter, number, and special character: !@#$%^&
最佳答案
我认为您应该创建自己的RegisterController来扩展Spring Security UI,如此处所述:http://burtbeckwith.github.com/grails-spring-security-ui/docs/manual/guide/10%20Customization.html
grails s2ui-override Register com.my.package
然后重写passwordValidator方法,将验证方法替换为所需的内容:
if (password && password.length() >= 8 && password.length() <= 64 &&
(!password.matches('^.*\\p{Alpha}.*$') ||
!password.matches('^.*\\p{Digit}.*$') || {
return 'command.password.error.strength'
}
如果您不想在密码中强制使用特殊字符(?!)
吉姆
关于grails - Spring Security密码验证(密码中的特殊字符),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7013745/