使用headers()和HTTP请求标头的PHP重定向 [英] PHP redirect using headers() and HTTP request headers
问题描述
我正在开发一个Web应用程序,该应用程序可以使用两个HTTP请求标头字段( user
和 role
)对用户进行身份验证.
I'm working on an web application which can authenticate users using two HTTP request headers fields: user
and role
.
使用公司的SSO服务,我想要实现以下目标:
Using the company's SSO service, I would like to achieve the following:
user --> SSO --> header(location: http://app, \
user : username, | --> application
role : rolename) /
基本上,我想从 SSO
页面上的 application
上重定向用户.SSO页面是一个小的PHP脚本,可找到正确的用户名和角色,然后执行对header()函数的调用:
Basically, I would like to redirect the user on application
from the SSO
page. The SSO page is a small PHP script which finds the correct username and role, and then perform calls to the header() function:
header('user: username');
header('role: rolename');
header('location: http://application/login');
问题是重定向期间似乎删除了 user
和 role
字段(我使用的是带有HTTP标头扩展名的Chrome来监视进程).
The problem is that the fields user
and role
seems to be removed during the redirection (I'm using Chrome with the HTTP headers extension to monitor the process).
此外,当我手动设置标题(使用修改标题Chrome扩展程序)时,一切正常.因此,我认为Web应用程序不是问题.
Also, when I'm setting the headers manually (using the modify headers Chrome extension), everything works fine. So I presume the web application is not the problem.
最后一件事:我不是Web应用程序的开发人员,这是一种商业产品.因此,我无法修改应用程序本身.
Last thing: I'm not the developer of the web application, which is a commercial product. So, there is no way for me to modify the application itself.
非常感谢您的帮助:)
推荐答案
无法在重定向时保留标头.在SO上看到这个问题:
There's no way to preserve headers on redirect. See this question on SO:
这篇关于使用headers()和HTTP请求标头的PHP重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!