Skip to content

The goal of this project is to demonstrate a consolidated implementation of Spring-Security combined Spring-Social (facebook & twitter) using Spring Roo as the scaffolding for the local user and connection store

Notifications You must be signed in to change notification settings

stmcpherson/Typical-Spring-Social-Security-With-Roo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 

Repository files navigation

The goal of this project is to demonstrate a consolidated implementation of Spring-Security combined Spring-Social (facebook & twitter) using Spring Roo as the scaffolding for the local user and connection store. 

The primary use case for this is to be a starting point for people who want a website that has a robust local user management system as well as uses Facebook et al. for connected authentication via Spring Social.

The basics of this project were constructed using the typicalSecurity roo plugin. ** http://code.google.com/p/spring-roo-addon-typical-security/


Setup:
    1) Install STS <or use eclipse if you like>
    2) Install MySQL
    3) Create a mysql schema called pangeansecurity
    4) git clone https://github.com/stmcpherson/Typical-Spring-Social-Security-With-Roo
    5) Import the project into STS
    6) Change the email.properties file to match your email account
    7) Change the database.properties file to match your mysql connection information
    8) Populate the springsocial.properties file with your twitter and facebook client ids and secrets
    9) Ensure your Facebook client account is configured as having an application url of
       http://localhost:8080/PangeanSecurity - this ensures that *both* signin and connect callbacks are
       permitted
    10) Ensure you have installed spring-social-jpa and spring-social-security into your local repository 
        ( https://github.com/michaellavelle/spring-social-jpa and https://github.com/socialsignin/spring-social-security )

Goal:
    1) To extend this stalk typicalSecurity project to integrate Spring-Social's Facebook and Twitter user authentication and connection management and to have that be persisted to a ROO implemented datastore. This should equivalent to functionality of the "showcase" example from https://github.com/SpringSource/spring-social-samples.git only modified to use a ROO backed local user system.

Approach:
    1) The intention is to integrate michaellavelle's work on the spring-social-security project with a typicalSecrity implementation. 
 
        
Modifications made by Michael Lavelle on 12 Dec 2011:

        Updated spring security to Spring 3.1 (some of spring-social's classes depend on 3.1 version of Spring Security) and changed construction of password encoder bean to allow for this update.

        Created new springsocial.properties to contain twitter and facebook client ids and secrets

        Added dependency to pom for spring-social-web,spring-social-facebook,spring-social-twitter and spring-social-security

        Added property placeholder configuration to webmvc-config.xml and added ProviderSignInController and ConnectController beans to webmvc-config.xml

        Added Config class containing Spring Social connection registry and connection registry locator, and registered facebook and twitter connection factories.

        Created CustomUsersConnectionRepository and added this and the ConnectionRepository to applicationConfig.xml

        Imported spring-social-security package (so we can use SpringSocialSecuritySignInService as our sign in adapter)

        Added this sign in adapter to SignUpController and call ProviderSignInUtils.handlePostSignUp and signInService.signIn(userId, connection, new ServletWebRequest(request));

        Added WebRequest parameter to SignUpController methods createForm and create - to pre-populate sign up form with facebook or twitter details

        Created a custom authentication filter and added this filter to security config

        Created TwitterConnectInterceptor and added ConnectController and registeredit

        Added twitter dependency and changed connect interceptor to twitter, and added twitter to connection factory registry

        Added twitterConnected view

Modifications made by Michael Lavelle on 16th Dec 2011 (fixes for issues #1,#2,#3 and #4)

        Refactored user account creation code into CreateUserAccountService

        Modified SignUpController so that it uses this new CreateUserAccountService for standard registration process.

        Created new SocialUserRegistrationForm to capture/validate registration details of users signing up using Social Provider (just contains email address for now)

        Added new methods to CreateUserAccountService for creation of user given a SocialUserRegistrationForm and a UserProfile obtained from 3rd party.

        Added new requestmapping method to SignUpController to handle submission of SocialUserRegistrationForms, and modified view form method to show different forms depending
        on whether user is signing up using standard process or via 3rd party.  Created to view for this form (socialindex.jspx) and registered it in views.xml

        Created UseEmailAddressIfAvailableConnectionSignUp which uses CreateUserAccountService to implicitly register Social Provider users after authentication if an email address is available and registered this with usersConnectionRepository.  

        Changed CustomUsersConnectionRepository so that it now extends SpringSocialSecurityJdbcUsersConnectionRepository which allows for nulls coming back from UseEmailAddressIfAvailableConnectionSignUp in event email address is not available.

        Added ability to Connect with Facebook after login (added new form submit to home page, added facebookConnected view. and changed requirements of project so that callback url in Facebook is
        configured to be base url (http://localhost:8080/PangeanSecurity) to allow for both /signin/facebook and /connect/facebook callback urls).

        Now passing "scope=email" request params to Facebook submit forms to request email address on signin

        Added FacebookConnectInterceptor and registered this with ConnectController

Modifications made by Michael Lavelle on 18th Dec 2011 (fix for issue #5)

        Forked https://github.com/mschipperheyn/spring-social-jpa to https://github.com/michaellavelle/spring-social-jpa

        Fixed issue with spring-social-jpa where 'mvn clean install' was generating compile errors and submitted pull
        request to bring fix in https://github.com/michaellavelle/spring-social-jpa back into https://github.com/mschipperheyn/spring-social-jpa )

        Added dependency to pom.xml for spring-social-jpa ( Use https://github.com/michaellavelle/spring-social-jpa until pull request is accepted)
        
        Created new Roo entity and aspects for UserConnection.

        Created RemoteUserConnectionAdapter to adapt UserConnection to a RemoteUser as required by spring-social-jpa

        Created an implementation of JpaTemplate for UserConnections and registered as a service as required by spring-social-jpa

        Modified CustomUsersConnectionRepository to now extend JpaUsersConnectionRepository

        Modified bean definition for connectionRepository to be an instance of JpaConnectionRepository
        
Modifiications made by Michael Lavelle on 20th Dec 2011 (fix for issue #6)

        Modified RooUserConnectionTemplate to make cleaner more efficient and added findMaxRankByUserIdAndProviderId and findUserIdsByProviderIdAndProviderUserIds finder methods to
        support this.

About

The goal of this project is to demonstrate a consolidated implementation of Spring-Security combined Spring-Social (facebook & twitter) using Spring Roo as the scaffolding for the local user and connection store

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages