缺少盐轮错误

时间:2013-06-29 22:31:26

标签: grails spring-security bcrypt

我正在尝试在instructions之后将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

知道我可能错过了什么?

1 个答案:

答案 0 :(得分:3)

事实证明,对于此实现,您必须指定介于4和31之间的值。我已更新了文档。