Eduardo Rodrigues
Eduardo Rodrigues

Reputation: 375

Grails Facebook Authentication plugin does not open FB auth page

I'm trying to use Grails Facebook Authentication plugin.

My goal is to use the Server Side Authentication, which is the default one.

As per the docs

It's preferred and a standard Login for Server-side Apps. After clicking on 'connect button' user gets redirected to special Facebook page, for authentication, and then redirected back to your app.

I was expecting to get the special FB page, but it's redirecting to straight to /j_spring_security_facebook_redirect instead. No FB page is showing up.

I'm not logged at FB

My config is like:

grails.plugins.springsecurity.facebook.domain.classname='br.com.fisgo.security.Credential'
grails.plugins.springsecurity.facebook.domain.relation = 'SameObject'

grails.plugins.springsecurity.facebook.secret = 'xxxx'
grails.plugins.springsecurity.facebook.appId = 'xxxxxx'

grails.plugins.springsecurity.facebook.filter.redirect.processUrl='/sign/facebookLogin'
grails.plugins.springsecurity.facebook.filter.type='redirect'

grails.plugins.springsecurity.facebook.taglib.button.text='Login com facebook'

I can't find out the problem.

The error I get on the redirect is:

| Error 2013-03-18 09:35:50,307 [http-bio-80-exec-1] ERROR [/].[default] - 
Servlet.service() for servlet [default] in context with path [] threw exception
 Message: Cannot create a session after the response has been committed Line | Method 
->> 1110 | runWorker in java.util.concurrent.ThreadPoolExecutor - - - - - - - - - - - 
- - - - - - - - - - - - - - - - - - - - - - - - - | 603 | run in 
java.util.concurrent.ThreadPoolExecutor$Worker ^ 722 | run . . . in java.lang.Threa

I have also found

ERROR facebook.DefaultFacebookAuthDao  - Can't find authority join class (br.com.fisgo.security.CredentialRole). Please configure 'grails.plugins.springsecurity.userLookup.authorityJoinClassName' value, or create your own 'List<GrantedAuthority> facebookAuthService.getRoles(user)'

The class is available

Upvotes: 0

Views: 682

Answers (1)

Svetozar Misljencevic
Svetozar Misljencevic

Reputation: 736

I was getting the same Cannot create a session after the response has been committed error.

The problem was that spring security was not allowing anonymous access to j_spring_security_facebook_redirect. Not sure how you configured grails spring security plugin but in our case this helped:

grails.plugins.springsecurity.interceptUrlMap = [
....
'/j_spring_security_facebook_redirect': ['IS_AUTHENTICATED_ANONYMOUSLY'],
....
]

To find the cause of your issue try to comment out line 59 response.sendRedirect(facebookAuthUtils.prepareRedirectUrl(getAbsoluteRedirectUrl(), facebookAuthUtils.requiredPermissions)) in FacebookAuthRedirectFilter.

Upvotes: 1

Related Questions