我正在尝试按照说明将 bcrypt 配置为 Grails 2.1.1 和 spring-security-core 1.2.7.3 中的加密算法。在 Config.groovy 中:
grails.plugins.springsecurity.password.algorithm = 'bcrypt'
grails.plugins.springsecurity.password.bcrypt.logrounds = 100
我之前使用的是盐,它工作正常,但是为了这个更改,我将我的 User.encodePassword() 编辑为一个参数版本。
当我在 Bootstrap.groovy 中创建一个新用户并尝试保存它时:
testUser = new User(username: 'name@example.com', enabled: true, password: 'password').save(flush: true)
我收到此错误:
Message: Missing salt rounds
Line | Method
->> 678 | hashpw in org.mindrot.jbcrypt.BCrypt
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 44 | encodePassword in grails.plugins.springsecurity.BCryptPasswordEncoder
| 87 | encodePassword . . . . . . . in grails.plugins.springsecurity.SpringSecurityService
| 42 | encodePassword in com.madeupname.app.User
| 32 | beforeInsert . . . . . . . . in ''
| 46 | onApplicationEvent in org.grails.datastore.mapping.engine.event.AbstractPersistenceEventListener
| 27 | doCall . . . . . . . . . . . in BootStrap$_closure1_closure3_closure4
| 314 | execute in grails.util.Environment$EnvironmentBlockEvaluator
| 295 | executeForEnvironment . . . in grails.util.Environment
| 270 | executeForCurrentEnvironment in ''
| 334 | innerRun . . . . . . . . . . in java.util.concurrent.FutureTask$Sync
| 166 | run in java.util.concurrent.FutureTask
| 1110 | runWorker . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor
| 603 | run in java.util.concurrent.ThreadPoolExecutor$Worker
^ 722 | run . . . . . . . . . . . . in java.lang.Thread
知道我可能错过了什么吗?