gpt4 book ai didi

grails - 使用Dynamodb的Grails Spring 安全性

转载 作者:行者123 更新时间:2023-12-02 14:12:55 24 4
gpt4 key购买 nike

我无法使用Spring Security和dynamodb登录到Grails应用程序中。

Grails是2.1,已安装的插件是spring-security核心和dynamodb。

用户和角色是由s2-quickstart创建的,唯一的修改是通过向用户,角色和userrole类添加String id和static mapWith =“dynamodb”(由于在dynamodb上的id是UUID生成的,因此需要String id)

Bootstrap是按照spring安全性教程编写的。

应用程序启动正常,并创建了dynamodb表和行。

我不断

身份验证失败:密码与存储的值不匹配

通过在LoginController上登录(我没有从教程中设置示例 Controller )。有任何想法吗?

最佳答案

如果您配置了多个数据源,那么我猜您这样做,因为您使用过mapWith beforeUpdate块将被多次调用。 (对于每个数据源一次)我将以下内容添加到我的用户域对象中,它可以正常工作。

transient hasBeforeInsert = false
transient hasBeforeUpdate = false

...

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

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

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

关于grails - 使用Dynamodb的Grails Spring 安全性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12138425/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com