Grails openid 插件 2.0.0 RC1:获取“没有此类属性:用户异常”

2024-03-09

已安装openid插件 http://grails.org/plugin/spring-security-openid2.0.0 RC1 到我的 grails 应用程序,但我得到 没有这样的属性:用户异常。有人可以建议应该做什么吗?

| Error 2013-10-28 00:11:55,169 [http-bio-8080-exec-6] ERROR errors.GrailsExceptionResolver  - MissingPropertyException occurred when processing request: [POST] /Test/login/openIdCreateAccount - parameters:
username: [email protected] /cdn-cgi/l/email-protection
password2: ***
password: ***
No such property: User for class: grails.plugin.springsecurity.openid.OpenIdRegisterCommand. Stacktrace follows:
Message: No such property: User for class: grails.plugin.springsecurity.openid.OpenIdRegisterCommand
   Line | Method
->> 265 | doCall   in grails.plugin.springsecurity.openid.OpenIdRegisterCommand$__clinit__closure1_closure2
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   195 | doFilter in grails.plugin.cache.web.filter.PageFragmentCachingFilter
|    63 | doFilter in grails.plugin.cache.web.filter.AbstractFilter
|    53 | doFilter in grails.plugin.springsecurity.web.filter.GrailsAnonymousAuthenticationFilter
|    49 | doFilter in grails.plugin.springsecurity.web.authentication.RequestHolderAuthenticationFilter
|    82 | doFilter in grails.plugin.springsecurity.web.authentication.logout.MutableLogoutFilter
|   895 | runTask  in java.util.concurrent.ThreadPoolExecutor$Worker
|   918 | run      in     ''
^   695 | run . .  in java.lang.Thread

该错误在 RC2 中并未修复,我两天前安装并遇到了同样的问题。实际上,OpenIdController中有4个错误。我将在下面提到 user2576874 在他的建议答案中修复的这些错误的详细信息及其解决方案:

1:第 267 行,该类在 OpenIdRegistrationCommand 的静态闭包中引用 grailsApplication bean。这里给出的解决方案是替换grailsApplication by: grails.util.Holders.getGrailsApplication()

2:第 286 行,当我们在 OpenId 登录回调后尝试注册用户时,正则表达式失败。这是一个更简单的正则表达式条件:

(!password.matches('^.*[a-zA-Z].*$') ||
!password.matches('^.*[0-9].*$') ||
!password.matches('^.*[!@#$%^&].*$')))

3:第183行,字段名称有错误:usernamePropertyName。正确的字段名称是usernamePropName如第 49 行所述。

4:运行代码会抛出 NullPointerException,因为 Role 类未定义类型。解决方案是将类类型添加到变量 Role 中,就像 User 和 UserRole 定义一样。在 OpenIdConroller 的第 255 行之后添加以下代码:

Role = grailsApplication.getClassForName(conf.authority.className)

Thx

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Grails openid 插件 2.0.0 RC1:获取“没有此类属性:用户异常” 的相关文章

随机推荐