【发布时间】:2019-03-27 18:12:31
【问题描述】:
我目前正在从事 SSO 项目。与 Google 一样,我们将 accounts.domain.com 作为 SSO 服务器。我们在三个不同的服务器(application1.com、application2.com、application3.com)上托管了三个应用程序。
只要用户想从这三个应用程序登录,用户就会被重定向到 SSO 服务器。如果用户提供的登录凭据正确,则意味着 SSO 服务器会生成 JWT 访问令牌。现在必须将生成的令牌附加到用户请求的应用程序响应标头,然后用户将被重定向到请求的应用程序以及“授权:承载 $token”。
我目前在将生成的令牌附加到响应标头时遇到问题。我目前正在使用 Slim 3 框架以及 lcobucci/jwt 作为 JWT 令牌。
我的代码:
$username = "Test";
$newResponse = $response->withHeader('Authorization' , "Bearer $token");
return $newResponse->withRedirect("http://application1.com/$username", 301);
当我在 accounts.domain.com 中调试 Response 标头时,似乎设置了 Authorization 标头。但在另一端(application1.com)没有收到授权标头。
截图
Initial Request from application1.com SSO Domain Redirect to grab the Cookie Validate the Session by the Grabbed Cookie and attach the Auth Header attached Authentication Success but no Authorization Headers Received
我的疑问是问题是否是由于 .htaccess 文件中的服务器配置(apache2)(或)我的实现本身是错误的。
指导我修复此错误。
环境详情:
- 服务器:Apache 2
- 框架:Slim 3
- JWT:lcobucci/jwt 包
【问题讨论】:
标签: php authentication jwt single-sign-on slim-3