I am successfully using Spring Security for register in login. Now I want to implement a login and register with Facebook Accounts via Spring Security Facebook Plugin.
I successfully ran the (demo application) but when I try to follow the documentation I do not get directed to Facebook inside my own app to perform a login, but always to:
http://localhost:8080/MYAPP/j_spring_security_facebook_redirect
Because I am using maven my dependencies are in a pom.xml, relevant section looks like following:
<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>
I also implemented the FacebookUser domain:
class FacebookUser {
long uid
String accessToken
Date accessTokenExpires
static belongsTo = [User]
static constraints = {
uid unique: true
}
/* static mapWith = "mongo" */
}
Inside my view I have following code for the connect button:
<facebookAuth:connect />
And my Config.groovy:
grails {
plugin {
springsecurity {
facebook {
domain.classname='de.<MYDOMAIN>.<MYAPP>.FacebookUser'
host='<MYDOMAIN>.de'
domain.appUserConnectionPropertyName = 'User'
appId = "<MYFBAPPID>"
secret = "<MYFBSECRET>"
So I don't understand where the mapping of "j_spring_security_facebook_redirect " is done in the demo app, and what is missing in my app do open the Facebook website instead of http://localhost:8080/MYAPP/j_spring_security_facebook_redirect
Thanks for any hints!
UPDATE:
Problems seem to be in my Config.groovy, because if I delete the configured providerNames and filterNames it works, but I there are configs that are needed so I cant delete them and need to add the missing filters and provider.
graisl.plugin.springsecurity.providerNames = ['...', '...']
graisl.plugin.springsecurity.filterChain.filterNames = ['...', '...']
I updated them with the needed filters an provider data (logged them in the demo app) but it does not find them:
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'
]
Startup error:
ERROR context.GrailsContextLoaderListener - Error initializing the application: No bean named 'FacebookAuthProvider' is defined
Message: No bean named 'FacebookAuthProvider' is defined