同时为多个社交网络启用OAuth2Sso [英] EnableOAuth2Sso simultaneously for multiple social networks

查看:42
本文介绍了同时为多个社交网络启用OAuth2Sso的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在实现一个需要提供 OAuth2 令牌授权并支持多种社交服务(google+、facebook 等)的 Spring Boot 应用程序.用户应该能够选择他喜欢的社交网络并使用 OAuth2 授权框架登录.我正在使用此处描述的方法实现上述方法 http://cloud.spring.io/spring-云安全/.

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 able to select his preferred social network and sign-in using the OAuth2 authorization framework. I am implementing the above using the approach described here http://cloud.spring.io/spring-cloud-security/.

目前我的 application.yml 看起来像这样

Currently my application.yml looks like this

spring:
  oauth2:
    client:
      clientId: {{my app's google id}
      clientSecret: {{my app's google secret code}} 
  etc...

另外,spring boot 主类标注为@EnableOAuth2Sso.

Also, the spring boot main class is annotated as @EnableOAuth2Sso.

我的问题是,通过上述方法,我只能使用一个社交网络(示例中的 google+).所以,我想知道是否有办法通过在 .yml 文件中以某种方式定义它们来同时支持多个社交网络.这是可能的还是我应该使用其他方法?

My problem is that with the above approach I can only use one social network for my purposes (google+ in the example). So, I would like to know if there is a way to support, simultaneously, multiple social networks by defining them somehow in the .yml file. Is this possible or should I use another approach?

感谢您的时间,

克里斯

推荐答案

@EnableOAuth2Sso 功能并非旨在支持多个提供程序作为简单的 YAML 声明.您需要在安全配置中安装 2 个单独的 OAuth2AuthenticationProcessingFilters 而不是使用它,每个都有不同的登录路径,然后从 UI 链接到它们.

The @EnableOAuth2Sso feature wasn't designed to support multiple providers as simple YAML declarations. Instead of using that you need to install 2 separate OAuth2AuthenticationProcessingFilters in your security configuration, each with a different login path, and then link to them from a UI.

这篇关于同时为多个社交网络启用OAuth2Sso的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆