简体   繁体   中英

Grails spring security using dynamodb

I am unable to log in my user into a grails application using spring security and dynamodb.

Grails is 2.1 and installed plugins are spring-security core and dynamodb latest.

User and role are creatd by s2-quickstart and its only modification is by adding String id and static mapWith = "dynamodb" to user, role and userrole classes (String id is required since id on dynamodb is UUID generated)

Bootstrap is as per spring security tutorial.

Application starts fine and dynamodb tables and rows are created.

I keep getting

Authentication failed: password does not match stored value

by loggin in on LoginController (I didn't set the sample controller from tutorial). Any ideas?

If you have more then one data source configured, which I'm guesing you do since you have used the mapWith the beforeUpdate block will be called more then once. (Once for each data source) I added the following to my user domain object and it works correctly.

transient hasBeforeInsert = false
transient hasBeforeUpdate = false

...

  def beforeInsert()
  {
    if(!hasBeforeInsert)
    {
      hasBeforeInsert = true
      encodePassword()
    }
  }

  def beforeUpdate()
  {
    if(!hasBeforeUpdate)
    {
      hasBeforeUpdate = true

      if(isDirty('password'))
      {
        encodePassword()
      }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM