【发布时间】:2017-06-03 23:30:14
【问题描述】:
我在 Spring 的 this tutorial 之后阅读并实现了我自己的 Auth 服务器。有多个 SSO 提供程序 - Facebook、Github 和自定义身份验证服务器。在本教程中,身份验证服务器包含对其他 SSO 提供程序的处理。
我有一个单独的资源服务器,它使用以下属性链接到我的身份验证服务器:
security.oauth2.resource.userInfoUri=http://localhost:9000/user
我可以使用 cUrl 命令从我的身份验证服务器获取令牌:
curl acme:acmesecret@localhost:9000/oauth/token -d grant_type=password -d username=user -d password=...
{"access_token":"aa49e025-c4fe-4892-86af-15af2e6b72a2","token_type":"bearer","refresh_token":"97a9f978-7aad-4af7-9329-78ff2ce9962d","expires_in":43199,"scope":"read write"}
但我不明白的是如何使用其他 SSO 提供程序从身份验证服务器获取此类令牌?资源服务器不应该关心我是如何获得令牌的,以及我是使用 Facebook 还是我的自定义身份验证服务器进行身份验证的。它应该简单地询问身份验证服务器什么是 Principal(登录用户),然后决定向他展示哪些资源,对吧?
我没有任何 UI,这将支持移动应用程序,因此我需要了解如何使用 REST 请求处理身份验证。
【问题讨论】:
标签: java spring-boot oauth-2.0 spring-security-oauth2