Spring Security OAuth plugin

1 vote
Dependency :
compile ":spring-security-oauth:2.0.1.1"
Custom repositories :
mavenRepo "http://grails.org/plugins"
mavenRepo "http://maven.springframework.org/release/"
mavenRepo "http://maven.springframework.org/snapshot/"
mavenRepo "http://maven.springframework.org/milestone/"
mavenRepo "http://repo.desirableobjects.co.uk/"

Documentation Source Issues

Summary

Adds OAuth-based authentication to the Spring Security plugin using the OAuth plugin. This plugin provides an OAuth realm that can easily be integrated into existing applications and a host of utility functions to make things like "log in with Twitter" almost trivial.

Installation

grails install-plugin spring-security-oauth

Description

Usage:

grails install-plugin spring-security-oauth

then, follow Spring Security Core and OAuth plugins documentation.

Once you have an user domain and configured provider names, go with:

grails s2-init-oauth [domain-class-package] [oauthid-class-name]

that creates an OAuthID class in the specified package.

Example:

grails s2-init-oauth com.yourapp OAuthID

Finally, add

static hasMany = [oAuthIDs: OAuthID]

to you user domain class and use this lines in your login view:

<oauth:connect provider="twitter" id="twitter-connect-link">Twitter</oauth:connect>
<oauth:connect provider="facebook" id="facebook-connect-link">Facebook</oauth:connect>
<oauth:connect provider="google" id="google-connect-link">Google</oauth:connect>
<oauth:connect provider="yahoo" id="yahoo-connect-link">Yahoo</oauth:connect>

That's it!