Multiple Facebook Apps backed by same Spring Boot

2019-07-23 04:44发布

问题:

So I was following the below (classic) tutorial for spring boot with facebook:

https://spring.io/guides/tutorials/spring-boot-oauth2/

Everything is working fine, however I can't find documentation to help me implement my specific use case. So here it goes:

  1. I'll have two facebook apps: one for the owner and another for the regular user
  2. These two facebook apps will ask for different permissions (ex: for owner app it'll ask for permission to post in the fanpage and for the regular user it'll only for basic user info)
  3. There will be two real application being one mobile (iOS and Android) and another browser based application (that's not really relevant)
  4. REST API will be secured based on roles, meaning that the owner will have the OWNER role and the regular user will have the REGULAR_USER role, so that, for example, the regular user won't be able to call the API to post on the fanpage
  5. Both applications will make it possible to login with or without facebook, because I need an users table to store more information and so
  6. Eventually regular user can login as owner if he/she downloads the **owner* app

So, to summarize, I need:

  1. Two facebook apps to be backed by same spring boot application
  2. The ability to authorize an user with APP ID X and assign OWNER role and the ability to authorize an user with APP ID Y and assign role REGULAR_USER
  3. To be able to configure (in the YML) two different facebook apps
  4. The user to be able to merge existing account with facebook if he authorizes later on

I guess that's it. I'll edit later if I find more useful information to provide.

Thanks!

回答1:

There is Dave Syer's project that shows how to set up an Authorization Server and multiple Resource Servers in the same app.

Similar question with solution: OAuth2 SSO for multiple resource servers with spring boot and jHipster