Call to undefined function Jasny\SSO\getallheaders()
MiragePresent opened this issue · 3 comments
Hello! I'm trying to implement SSO in my projects, but it doesn't work because I'm using nginx and php-fpm therefore getallheaders
function is not available. The problem in getBrokerSessionID
method. Can you add a fix for it?
Hi! The getallheaders() isn't always available. You could use this code to make the function available if it's not present (got it from PHP.net):
{
function getallheaders()
{
$headers = [];
foreach ($_SERVER as $name => $value)
{
if (substr($name, 0, 5) == 'HTTP_')
{
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
}
}
return $headers;
}
}
The only value actually required is the Authorization header, so you could get it out of the $_SERVER global instead of using the original getallheaders() or the above function.
I see. I just think would be great to create new method like this:
protected function getAllHeaders()
{
if (!function_exists('getallheaders')) {
$headers = [];
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') {
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
}
}
return $headers;
}
return getallheaders();
}
and use this method in getBrokerSessionID
If you add the function in general, you can just use Jasny's package without having to modify it.