SSO OAuth2Authentication 会话和服务器端 http 请求

SSO OAuth2Authentication session and server side http request

我对向实施相同 SSO 身份验证的 Web 服务器发出服务器端 http 请求的机会感兴趣。

所以假设我有:hello.orghey.com 指向同一个 SSO 服务器。 我登录后 hello.org 我得到:

OAuth2Authentication authenticationObject = (OAuth2Authentication) principal; 

现在我想触发从 hello.org 服务器到 hey.com[=12= 的 http 请求]

Request.Get("hey.com/get_data").execute().returnContent().asString(); 

但是我遇到了身份验证错误代码 401。

如何从 OAuth 对象中检索所有必需的令牌并使我的请求得到验证?

站点 hello.org 不应使用提供给调用 hello.org 的客户端的令牌来调用 hey.com。该令牌将被视为经过身份验证的用户与 hello.org.

之间的合同

hello.org 服务器需要它自己的客户端,该客户端被授权访问 hey.com。

因此,解决此问题的一种常见方法是创建一个 "hello.org to hey.com" 客户端,使用针对 sso 提供程序的密钥或证书身份验证,然后使用那里提供的令牌调用 hey.com,然后中继将信息返回给 hello.org.

的用户

现在,如果您想通过 hello.org 调用 hey.com,而用户不知道 hey.com 曾参与信息提供。

另一方面,如果您想让用户通过 hello.org 登录来访问 hello.org 和 hey.com,您应该检查 OpenId 或 SAML,因为基本的 Oauth并不是真正为 SSO 或资源共享而设计的。