This is an example application of my blog entries that describe how you can integration Spring Social and Spring Security. These blog posts are:
- Adding Social Sign In to a Spring MVC Web Application: Configuration
- Adding Social Sign In to a Spring MVC Web Application: Registration and Login
This example application uses
- Spring Framework 3.2.X
- Spring Social 1.1.0
- Spring Security 3.2.0
This example application has the following software prerequisites:
- JDK 7
- Maven 3
- MySQL 5.6.X
- Twitter application (Enable the "allow this application to be used to Sign in with Twitter" checkbox)
- Facebook application (Select "website with Facebook login" when you are asked how your application integrates with FB)
You can create the required applications by following these links:
If you don't know how to create these applications, read the following tutorials:
This section describes the steps which are required to run the example application.
- Ensure that you have installed all required software.
- Ensure that you have created a Facebook and a Twitter application used with this example.
- Create a MySQL database for the example application.
You can configure the application by following these steps:
-
Configure the database connection. The database connection is configured in the file profiles/dev/config.properties.
db.driver=com.mysql.jdbc.Driver db.url=jdbc:mysql://localhost:3306/socialtwitter db.username=socialtwitter db.password=password
-
Configure the Facebook application. You can configure your Facebook application by creating a file src/main/resources/social.properties The content of this file looks as follows:
facebook.app.id=foo facebook.app.secret=bar
-
Configure the Twitter application. You can configure your twitter application by adding the following configuration to the file src/main/resources/social.properties:
twitter.consumer.key=foo twitter.consumer.secret=bar
You can initialize the database by running the following command at the command prompt:
mvn resources:resources liquibase:update -P dev -e -X
You can run the application by running the following command at the command prompt:
gradle tomcatRun
If running locally, the webpage is available at http://localhost:8080/spring-social-sign-in
If you want to deploy the application to Tomcat, you have to use Tomcat 7 or newer.
-
You can run unit tests by running the following command at the command prompt:
gradle test