Using Facebook to authenticate users
Although Facebook does not implement OpenID Connect, it can also be used for authentication since it provides user identity information and the authentication context. Thus, the client application (or Relying Part) is able to recognize the user as being present and who the user claims to be. After reading this recipe, you will see how to use Spring Security OAuth2 to provide OAuth 2.0 as the basis for authentication (actually, OAuth 2.0 is about authorization, but it can be used as the basis for authentication).
Getting ready
To run this recipe, you will need Java 8, Maven, Spring Web, and Spring Security. To ease the project creation step, use Spring Initializr athttp://start.spring.io/and define the dependencies: asWeb
,JPA
,H2
,Thymeleaf
, andSecurity
(which will properly declare all the Spring Boot starters needed for this recipe). Do not forget to set up the Artifact
and Group
names.
How to do it...
This recipe creates the facebook-login-oauth2
project, which...