Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot OAuth2 linking internal users with Facebook/Google login

I have implemented a Spring Boot application with AngularJS frontend. Have also setup users along with their permissions. Right now I am able to login with any of these users and is working well with Spring security. I would like to turn this traditional login flow into a Facebook/Google OAuth login flow, where in I want the users to use their Facebook/Google account to log in and they will be mapped to their internal users automatically. This will help me in getting rid of maintaining passwords of these users.

I found many articles talking about setting up OAuth with Spring Boot and how can Facebook/Google login be integrated with a Spring Boot application. But I am having difficulty in finding an article which talks about linking a Facebook/Google user with internal users.

How should I go about this?

like image 494
bighi Avatar asked Jul 27 '17 11:07

bighi


1 Answers

  1. Look for a user with the associated facebook/google userID.
  2. If that user does not exist you request an email address and try to match it with an existing legacy account.
  3. If you do not get a email adress for any reason (not acceping the authorization request for example) you could show a popup box asking for the email adress explaining why you need it.
  4. You then locate the legacy user and merge it adding the facebook/google ID to look it up in the future.
  5. If no user is found with the email adress you either refuse the user or create a new account.

you should be able to do all of this by implementing your own AuthenticationProvider

like image 96
p.streef Avatar answered Oct 19 '22 01:10

p.streef