简体   繁体   English

使用Dynamodb的Grails春季安全性

[英]Grails spring security using dynamodb

I am unable to log in my user into a grails application using spring security and dynamodb. 我无法使用Spring Security和dynamodb登录到Grails应用程序中。

Grails is 2.1 and installed plugins are spring-security core and dynamodb latest. Grails是2.1,安装的插件是spring-security核心和dynamodb。

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) 用户和角色是由s2-quickstart创建的,它的唯一修改是通过向用户,角色和userrole类添加String id和static mapWith =“ dynamodb”(因为在dynamodb上的id是UUID生成的,所以需要String id)

Bootstrap is as per spring security tutorial. Bootstrap是按照spring安全性教程编写的。

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). 通过在LoginController上登录(我没有从教程中设置示例控制器)。 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. 如果您配置了多个数据源,那么我猜您这样做,因为您使用过mapWith beforeUpdate块将被调用多次。 (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()
      }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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