EnableOAuth2Sso simultaneously for multiple social networks

后端 未结 4 2055
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-19 18:22

I am implementing a spring boot application that needs to provide OAuth2 token authorization and support multiple social services (google+, facebook etc). The user should be

4条回答
  •  Happy的楠姐
    2020-12-19 19:08

    I also stumbled upon this and many other questions about multiple authentication provider support. Syer's answer that core @EnableOAuth2Sso annotation wasn't designed for this was actually very helpful. It made me look elsewhere.

    Benefiting from Nimbus OAuth library I designed another approach. It probably isn't clean and nice, but it does what I was planning. Separate authentication providers are defined in properties and selected based on URI path.

    This is what I came up with: https://bitbucket.org/klaalo/orcidconnect/src/f3e4fada9827e47bd33efd579fd020c41e37ee2a/src/main/java/fi/csc/orcidconnect/oauth2client/

    Basically, a provider is selected based on a decision made by DelegatingAuthenticationProviderEndpoint in SecurityConfiguration (on default package). AuthenticationProcessingFilter is waiting for authentication events and making redirects to authentication providers. On return it will validate received code and carries AuthenticationToken for custom AuthenticationProvider to evaluate.

    Received UserDetails are persisted to User object in a Map.

    Hope this helps.

提交回复
热议问题