Merge branch 'release/3.2.2'

Conflicts:
	composer.json
This commit is contained in:
Alex Bilbie 2014-07-23 16:10:02 +01:00
commit 94369abd60
5 changed files with 17 additions and 9 deletions

View File

@ -1,5 +1,9 @@
# Changelog
## 3.2.2 (released 2014-07-23)
* Fix Resource server Request HTTP header access (Issue #188)
## 3.2 (released 2014-04-16)
* Added the ability to change the algorithm that is used to generate the token strings (Issue #151)

View File

@ -1,6 +1,7 @@
{
"name": "league/oauth2-server",
"description": "A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.",
"version": "3.2.2",
"license": "MIT",
"require": {
"php": ">=5.4.0"

View File

@ -163,9 +163,9 @@ class Resource
// include the "WWW-Authenticate" response header field
// matching the authentication scheme used by the client.
// @codeCoverageIgnoreStart
if ($error === 'insufficient_scope') {
if ($error === 'invalid_token') {
$authScheme = null;
$request = new Request();
$request = Request::buildFromGlobals();
if ($request->server('PHP_AUTH_USER') !== null) {
$authScheme = 'Basic';
} else {

View File

@ -76,22 +76,25 @@ class Request implements RequestInterface
protected function readHeaders()
{
if (function_exists('getallheaders')) {
if (function_exists('apache_request_headers')) {
// @codeCoverageIgnoreStart
$headers = getallheaders();
$headers = apache_request_headers();
} elseif (function_exists('http_get_request_headers')) {
$headers = http_get_request_headers();
} else {
// @codeCoverageIgnoreEnd
$headers = array();
foreach ($this->server() as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') {
$name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))));
// HTTP_FOO_BAR becomes FOO-BAR
$name = str_replace(array('HTTP_', '_'), array('', '-'), $name);
$headers[$name] = $value;
}
}
}
return $this->normalizeHeaders($headers);
}
}
protected function getPropertyValue($property, $index = null, $default = null)
{
@ -143,4 +146,4 @@ class Request implements RequestInterface
return $key;
}
}
}

View File

@ -38,8 +38,8 @@ class Resource_Server_test extends PHPUnit_Framework_TestCase
public function test_getExceptionHttpHeaders()
{
$this->assertEquals(array('HTTP/1.1 400 Bad Request'), League\OAuth2\Server\Resource::getExceptionHttpHeaders('invalid_request'));
$this->assertEquals(array('HTTP/1.1 401 Unauthorized'), League\OAuth2\Server\Resource::getExceptionHttpHeaders('invalid_token'));
$this->assertContains('HTTP/1.1 403 Forbidden', League\OAuth2\Server\Resource::getExceptionHttpHeaders('insufficient_scope'));
$this->assertContains('HTTP/1.1 401 Unauthorized', League\OAuth2\Server\Resource::getExceptionHttpHeaders('invalid_token'));
$this->assertEquals(array('HTTP/1.1 403 Forbidden'), League\OAuth2\Server\Resource::getExceptionHttpHeaders('insufficient_scope'));
}
public function test_setRequest()