Authorization header fixes

This commit is contained in:
Alex Bilbie 2013-02-07 16:16:09 +00:00
parent 55d68bd105
commit 89f3c35466
2 changed files with 11 additions and 7 deletions

View File

@ -161,7 +161,7 @@ class ResourceServer
protected function determineAccessToken() protected function determineAccessToken()
{ {
if ($header = $this->getRequest()->header('Authorization')) { if ($header = $this->getRequest()->header('Authorization')) {
$access_token = trim(str_replace('Bearer', '', $header)); $access_token = base64_decode(trim(str_replace('Bearer', '', $header)));
} else { } else {
$method = $this->getRequest()->server('REQUEST_METHOD'); $method = $this->getRequest()->server('REQUEST_METHOD');
$access_token = $this->getRequest()->{$method}($this->tokenKey); $access_token = $this->getRequest()->{$method}($this->tokenKey);

View File

@ -65,11 +65,15 @@ class Request implements RequestInterface
protected function readHeaders() protected function readHeaders()
{ {
$headers = array(); if (function_exists('getallheaders')) {
foreach ($this->server() as $name => $value) { $headers = getallheaders();
if (substr($name, 0, 5) == 'HTTP_') { } else {
$name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5))))); $headers = array();
$headers[$name] = $value; foreach ($this->server() as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') {
$name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))));
$headers[$name] = $value;
}
} }
} }
@ -91,4 +95,4 @@ class Request implements RequestInterface
return $this->{$property}[$index]; return $this->{$property}[$index];
} }
} }