From 89f3c35466bebf187837d9c619b976871c516a48 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Thu, 7 Feb 2013 16:16:09 +0000 Subject: [PATCH] Authorization header fixes --- src/OAuth2/ResourceServer.php | 2 +- src/OAuth2/Util/Request.php | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/OAuth2/ResourceServer.php b/src/OAuth2/ResourceServer.php index 2f7ef991..6bf3578c 100644 --- a/src/OAuth2/ResourceServer.php +++ b/src/OAuth2/ResourceServer.php @@ -161,7 +161,7 @@ class ResourceServer protected function determineAccessToken() { if ($header = $this->getRequest()->header('Authorization')) { - $access_token = trim(str_replace('Bearer', '', $header)); + $access_token = base64_decode(trim(str_replace('Bearer', '', $header))); } else { $method = $this->getRequest()->server('REQUEST_METHOD'); $access_token = $this->getRequest()->{$method}($this->tokenKey); diff --git a/src/OAuth2/Util/Request.php b/src/OAuth2/Util/Request.php index 1b201057..eefe37d0 100644 --- a/src/OAuth2/Util/Request.php +++ b/src/OAuth2/Util/Request.php @@ -65,11 +65,15 @@ class Request implements RequestInterface protected function readHeaders() { - $headers = array(); - 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; + if (function_exists('getallheaders')) { + $headers = getallheaders(); + } else { + $headers = array(); + 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]; } -} +} \ No newline at end of file