gpt4 book ai didi

spring - Grails Spring Security Facebook插件-“连接”按钮不会重定向到Facebook

转载 作者:行者123 更新时间:2023-12-02 16:00:31 26 4
gpt4 key购买 nike

我已成功使用Spring Security在登录中注册。现在,我想通过Spring Security Facebook Plugin实现登录并在Facebook帐户中注册。

我成功运行了(demo application),但是当我尝试遵循documentation时,我并没有在自己的应用程序中定向到Facebook进行登录,而是始终执行以下操作:

http://localhost:8080/MYAPP/j_spring_security_facebook_redirect

因为我正在使用maven,所以我的依赖项位于pom.xml中,因此相关部分如下所示:

<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>spring-security-core</artifactId>
<version>2.0-RC4</version>
<scope>compile</scope>
<type>zip</type>
</dependency>

<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-core</artifactId>
<version>1.1.0.RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-facebook</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>

<!-- Facebook Spring Social Plugin -->
<dependency>
<groupId>org.grails.plugins</groupId>
<artifactId>spring-security-facebook</artifactId>
<version>0.17</version>
<type>zip</type>
</dependency>

我还实现了FacebookUser域:
class FacebookUser {

long uid
String accessToken
Date accessTokenExpires

static belongsTo = [User]

static constraints = {
uid unique: true
}

/* static mapWith = "mongo" */
}

在我的 View 内部,我有以下用于连接按钮的代码:
<facebookAuth:connect />

而我的Config.groovy:
grails {
plugin {
springsecurity {
facebook {
domain.classname='de.<MYDOMAIN>.<MYAPP>.FacebookUser'
host='<MYDOMAIN>.de'

domain.appUserConnectionPropertyName = 'User'
appId = "<MYFBAPPID>"
secret = "<MYFBSECRET>"

所以我不明白在演示应用程序中“j_spring_security_facebook_redirect”的映射在哪里完成,而我的应用程序中缺少的内容确实打开了Facebook网站而不是 http://localhost:8080/MYAPP/j_spring_security_facebook_redirect

感谢您的提示!

更新:

问题似乎出在我的Config.groovy中,因为如果我删除已配置的providerNames和filterNames,它可以工作,但是我需要一些配置,因此无法删除它们,并且需要添加缺少的过滤器和提供程序。
graisl.plugin.springsecurity.providerNames = ['...', '...']
graisl.plugin.springsecurity.filterChain.filterNames = ['...', '...']

我用所需的筛选器更新了提供者数据(在演示应用程序中记录了它们),但找不到它们:
providerNames = [
'tokenAuthenticationProvider',
'daoAuthenticationProvider',
'rememberMeAuthenticationProvider',
'FacebookAuthProvider'
]

filterChain.filterNames = [
'securityContextPersistenceFilter',
'logoutFilter',
'authenticationProcessingFilter',
'tokenAuthenticationFilter',
'basicAuthenticationFilter',
'rememberMeAuthenticationFilter',
'anonymousAuthenticationFilter',
'exceptionTranslationFilter',
'filterInvocationInterceptor',
/* Facebook Security Filters */
'MutableLogoutFilter',
'FacebookAuthRedirectFilter',
'RequestHolderAuthenticationFilter',
'SecurityContextHolderAwareRequestFilter',
'GrailsRememberMeAuthenticationFilter',
'GrailsAnonymousAuthenticationFilter',
'ExceptionTranslationFilter',
'FilterSecurityInterceptor'
]

启动错误:
ERROR context.GrailsContextLoaderListener  - Error initializing the  application: No bean named 'FacebookAuthProvider' is defined

消息:未定义名为“FacebookAuthProvider”的bean

最佳答案

终于解决了,这是我与 grails.plugin.springsecurity 相关的Config.groovy ...现在:

            providerNames = [
'tokenAuthenticationProvider',
'daoAuthenticationProvider',
'rememberMeAuthenticationProvider',
/* Facebook Security Provider */
'facebookAuthProvider'
]

filterChain.filterNames = [
'securityContextPersistenceFilter',
'logoutFilter',
'authenticationProcessingFilter',
'tokenAuthenticationFilter',
'basicAuthenticationFilter',
'rememberMeAuthenticationFilter',
'anonymousAuthenticationFilter',
'exceptionTranslationFilter',
'filterInvocationInterceptor',
/* Facebook Security Filters */
'facebookAuthRedirectFilter',
'securityContextHolderAwareRequestFilter',
'exceptionTranslationFilter',
]

关于spring - Grails Spring Security Facebook插件-“连接”按钮不会重定向到Facebook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31559533/

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