Grails:Spring Security插件之间不兼容?

时间:2015-03-12 10:28:42

标签: facebook grails spring-security spring-security-oauth2 google-login

我正在使用Grails 2.4.4,我需要通过Facebook,Twitter和Google添加登录选项。我已将以下插件添加到BuildConfig.groovy文件...

plugins {
....
compile ":spring-security-core:2.0-RC4"
compile ":spring-security-facebook:0.17"
compile ":spring-security-twitter:0.6"

在设置了许多其他参数并添加所需的gsp标签后,我可以从Facebook和Twitter登录/注销。为了支持Google登录,我添加了以下插件...

compile ":spring-security-oauth:2.1.0-RC4"
compile ':spring-security-oauth-google:0.3.1'

我添加了plugin docs中指定的必需参数。现在,如果我尝试登录Facebook或Twitter,当我点击登录链接时,我的浏览器会出现以下HTTP状态404错误:

message /TestSecurity/j_spring_twitter_security_check

description The requested resource is not available.

和...

message /TestSecurity/j_spring_security_facebook_redirect

description The requested resource is not available.

Google登录链接不会产生相同的错误,但会使用不同的登录链接:

/TestSecurity/oauth/google/authenticate?redirectUrl

有人可以解释为什么为Oauth / Google添加插件会破坏之前的功能和/或建议一种纠正它的方法吗?

这是Debug输出(根据要求):

2015-03-12 12:56:02,601 [localhost-startStop-1] DEBUG twitter.DefaultTwitterAuthDao  - Init default Twitter Authentication Dao...
2015-03-12 12:56:02,617 [localhost-startStop-1] DEBUG twitter.DefaultTwitterAuthDao  - Twitter Authentication Dao is ready.
|Server running. Browse to http://localhost:8080/TestSecurity
....2015-03-12 12:56:22,834 [http-bio-8080-exec-4] DEBUG filter.GrailsAnonymousAuthenticationFilter  - Populated SecurityContextHolder with anonymous token: 'grails.plugin.springsecurity.authentication.GrailsAnonymousAuthenticationToken@dc41564: Principal: org.springframework.security.core.userdetails.User@dc730200: Username: __grails.anonymous.user__; Password: [PROTECTED]; Enabled: false; AccountNonExpired: false; credentialsNonExpired: false; AccountNonLocked: false; Granted Authorities: ROLE_ANONYMOUS; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null; Granted Authorities: ROLE_ANONYMOUS'
2015-03-12 12:56:22,958 [http-bio-8080-exec-5] DEBUG filter.GrailsAnonymousAuthenticationFilter  - Populated SecurityContextHolder with anonymous token: 'grails.plugin.springsecurity.authentication.GrailsAnonymousAuthenticationToken@dc41564: Principal: org.springframework.security.core.userdetails.User@dc730200: Username: __grails.anonymous.user__; Password: [PROTECTED]; Enabled: false; AccountNonExpired: false; credentialsNonExpired: false; AccountNonLocked: false; Granted Authorities: ROLE_ANONYMOUS; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null; Granted Authorities: ROLE_ANONYMOUS'
2015-03-12 12:56:23,427 [http-bio-8080-exec-5] DEBUG facebook.FacebookAuthTagLib  - Do default server-side authentication redirect
2015-03-12 12:56:23,433 [http-bio-8080-exec-5] DEBUG facebook.FacebookAuthTagLib  - Apply server side connect
2015-03-12 12:56:23,944 [http-bio-8080-exec-9] DEBUG filter.GrailsAnonymousAuthenticationFilter  - Populated SecurityContextHolder with anonymous token: 'grails.plugin.springsecurity.authentication.GrailsAnonymousAuthenticationToken@dc41564: Principal: org.springframework.security.core.userdetails.User@dc730200: Username: __grails.anonymous.user__; Password: [PROTECTED]; Enabled: false; AccountNonExpired: false; credentialsNonExpired: false; AccountNonLocked: false; Granted Authorities: ROLE_ANONYMOUS; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null; Granted Authorities: ROLE_ANONYMOUS'
2015-03-12 12:56:23,944 [http-bio-8080-exec-7] DEBUG filter.GrailsAnonymousAuthenticationFilter  - Populated SecurityContextHolder with anonymous token: 'grails.plugin.springsecurity.authentication.GrailsAnonymousAuthenticationToken@dc41564: Principal: org.springframework.security.core.userdetails.User@dc730200: Username: __grails.anonymous.user__; Password: [PROTECTED]; Enabled: false; AccountNonExpired: false; credentialsNonExpired: false; AccountNonLocked: false; Granted Authorities: ROLE_ANONYMOUS; Credentials: [PROTECTED]; Authenticated: true; Details: org.springframework.security.web.authentication.WebAuthenticationDetails@b364: RemoteIpAddress: 0:0:0:0:0:0:0:1; SessionId: null; Granted Authorities: ROLE_ANONYMOUS'
...

我从控制台输出的末尾删除了大约十几行,因为它们都包含相同的信息。当我登录时,我已启用spring-security-ui模块,以使用该模块提供的登录页面覆盖默认登录页面。单击登录链接时,将生成filter.GrailsAnonymousAuthentication输出。

提前致谢...

0 个答案:

没有答案