(Quick Reference)

4 Configuration - Reference Documentation

Authors: Igor Artamonov (igor@artamonov.ru)

Version: 0.17

4 Configuration

Basic Configuration

Make sure that you have installed and configured spring-security-core plugin before this step.

Calling `grails s2-init-facebook` will make default configuration of plugin for you, make sure that you have configuration in your `Config.groovy` like:

grails.plugin.springsecurity.facebook.domain.classname='<your FacebookUser domain>'
grails.plugin.springsecurity.facebook.secret = '<Facebook secret for your app>'
grails.plugin.springsecurity.facebook.appId = '<Facebooks's app ID>'

Or you can skip `grails s2-init-facebook` step, and make such configuration by yourself.

When you have valid configuration you can put Facebook Connect button in you GSP:

<facebookAuth:connect permissions="email,user_about_me"/>

You don't need to add anything else.

4.1 Facebook App Config

NameDefault Value
grails.plugin.springsecurity.facebook.secretmust be specified
grails.plugin.springsecurity.facebook.appIdmust be specified

NameDefault Value

For a list of all possible permissions see https://developers.facebook.com/docs/reference/login/#permissions

4.2 Domains

NameDefault ValueValues
  • domain.classname - name of your domain class, used to store Facebook User details (uid, access_token, etc). Could be same as configured for Spring Security Core, or a own domain, just for Facebook User details.

If you're using own domain for Facebook user (a joined to main User) you should specify domain.appUserConnectionPropertyName: it's how your domain class is related to main (used by Spring Security Core) user domain. It's the name of the property, usually defined as static belongsTo = user: User in your Facebook User domain class.

User creation/initialization

NameDefault Value
grails.plugin.springsecurity.facebook.autoCreate.roles'ROLE_USER', 'ROLE_FACEBOOK'

List of roles for user created by the plugin.

4.3 Login Button

Button configuration

NameDefault Value
grails.plugin.springsecurity.facebook.taglib.button.text'Login with Facebook'

Button for Server Side authentication (default)

Standard <img … /> will be used for button, with following extra configuration options:

NameDefault Value
grails.plugin.springsecurity.facebook.taglib.button.imgan url for image distributed with plugin
  • img - url of a default image to use for button

Button for Client Side authentication

At this case a HTML button, provided by Facebook JS SDK, will be user.

NameDefault Value
  • language - language for Facebook Javascript SDK. You could also pass this option as a lang attribute for :connect or :init tags

4.4 Plugin Internals

NameDefault Value
grails.plugin.springsecurity.facebook.autoCreate.roles'ROLE_USER', 'ROLE_FACEBOOK'
  • autoCreate.enabled - enable/disabled automatic creation of Application User for a new Facebook user (when FB user first time authenticates)
  • autoCreate.roles - list of roles to set to a newly created user (if enabled)

NameDefault Value

Set a hostname of current app, could be used when user logged out, but FB didn't clear all cookies for domain. Note: it's host name, not url. Like `example.com`

4.5 Authentication Types

NameDefault Value
  • type - type of authentication, can be transparent, cookieDirect, redirect or json.

You can specify list of filters as a list 'redirect', 'json' or comma-separated string:


Configuration for REDIRECT filter

NameDefault Value
grails.plugin.springsecurity.facebook.filter.redirect.processUrlnot set
grails.plugin.springsecurity.facebook.filter.redirect.failureHandlernot set
grails.plugin.springsecurity.facebook.filter.redirect.successHandlernot set
  • redirectFromUrl - it's the url that will redirect user to special Facebook Authentication URL. You can put link to/redirect user to redirectFromUrl when you want to use Facebook authentication. This url is used by default <facebook:connect /> button.
  • if filter.redirect.processUrl is not then, then default filter.processUrl will be used
  • failureHandler - a name of the bean that implements AuthenticationFailureHandler
  • successHandler - a name of the bean that implements AuthenticationSuccessHandler

Configuration for TRANSPARENT filter


Configuration for COOKIEDIRECT filter

NameDefault Value
grails.plugin.springsecurity.facebook.filter.cookieDirect.processUrlnot set
grails.plugin.springsecurity.facebook.filter.cookieDirect.failureHandlernot set
grails.plugin.springsecurity.facebook.filter.cookieDirect.successHandlernot set

Configuration for JSON filter

NameDefault Value
  • type could be json (default) or jsonp
  • methods - allowed HTTP methods. Notice that it's used only for JSON, for JSONP it will be forced to 'GET'