Skip to content

Commit

Permalink
Merge pull request #105 from SebScoFr/master
Browse files Browse the repository at this point in the history
Fixing HTTP status code definition
  • Loading branch information
GuilhemN committed Jan 30, 2018
2 parents 486a6a5 + 5921db2 commit a41fef6
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 44 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
language: php

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
- hhvm

install:
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
}
],
"require": {
"php": ">=5.3.2",
"symfony/http-foundation": "~2.0|~3.0|~4.0"
"php": "^5.5.9|>=7.0.8",
"symfony/http-foundation": "~3.0|~4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0"
Expand Down
74 changes: 38 additions & 36 deletions lib/OAuth2.php

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion lib/OAuth2RedirectException.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace OAuth2;

use Symfony\Component\HttpFoundation\Response;

/**
* Redirect the end-user's user agent with error message.
*
Expand Down Expand Up @@ -37,7 +39,7 @@ class OAuth2RedirectException extends OAuth2ServerException
*/
public function __construct($redirectUri, $error, $errorDescription = null, $state = null, $method = OAuth2::TRANSPORT_QUERY)
{
parent::__construct(OAuth2::HTTP_FOUND, $error, $errorDescription);
parent::__construct(Response::HTTP_FOUND, $error, $errorDescription);

$this->method = $method;
$this->redirectUri = $redirectUri;
Expand Down
3 changes: 2 additions & 1 deletion tests/Fixtures/OAuth2GrantExtensionJwtBearer.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use OAuth2\OAuth2ServerException;
use OAuth2\Model\IOAuth2Client;
use OAuth2\Tests\Fixtures\OAuth2StorageStub;
use Symfony\Component\HttpFoundation\Response;

class OAuth2GrantExtensionJwtBearer extends OAuth2StorageStub implements IOAuth2GrantExtension
{
Expand All @@ -15,7 +16,7 @@ class OAuth2GrantExtensionJwtBearer extends OAuth2StorageStub implements IOAuth2
public function checkGrantExtension(IOAuth2Client $client, $uri, array $inputData, array $authHeaders)
{
if ('urn:ietf:params:oauth:grant-type:jwt-bearer' !== $uri) {
throw new OAuth2ServerException(OAuth2::HTTP_BAD_REQUEST, OAuth2::ERROR_UNSUPPORTED_GRANT_TYPE);
throw new OAuth2ServerException(Response::HTTP_BAD_REQUEST, OAuth2::ERROR_UNSUPPORTED_GRANT_TYPE);
}

if (!isset($inputData['jwt'])) {
Expand Down
3 changes: 2 additions & 1 deletion tests/Fixtures/OAuth2GrantExtensionLifetimeStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use OAuth2\IOAuth2GrantExtension;
use OAuth2\OAuth2ServerException;
use OAuth2\Model\IOAuth2Client;
use Symfony\Component\HttpFoundation\Response;

class OAuth2GrantExtensionLifetimeStub extends OAuth2StorageStub implements IOAuth2GrantExtension
{
Expand All @@ -14,7 +15,7 @@ class OAuth2GrantExtensionLifetimeStub extends OAuth2StorageStub implements IOAu
public function checkGrantExtension(IOAuth2Client $client, $uri, array $inputData, array $authHeaders)
{
if ('http://company.com/fb_access_token_time_limited' !== $uri) {
throw new OAuth2ServerException(OAuth2::HTTP_BAD_REQUEST, OAuth2::ERROR_UNSUPPORTED_GRANT_TYPE);
throw new OAuth2ServerException(Response::HTTP_BAD_REQUEST, OAuth2::ERROR_UNSUPPORTED_GRANT_TYPE);
}

if (!isset($inputData['fb_access_token'])) {
Expand Down
3 changes: 2 additions & 1 deletion tests/Fixtures/OAuth2GrantExtensionStub.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use OAuth2\OAuth2ServerException;
use OAuth2\Model\IOAuth2Client;
use OAuth2\Tests\Fixtures\OAuth2StorageStub;
use Symfony\Component\HttpFoundation\Response;

class OAuth2GrantExtensionStub extends OAuth2StorageStub implements IOAuth2GrantExtension
{
Expand All @@ -15,7 +16,7 @@ class OAuth2GrantExtensionStub extends OAuth2StorageStub implements IOAuth2Grant
public function checkGrantExtension(IOAuth2Client $client, $uri, array $inputData, array $authHeaders)
{
if ('http://company.com/fb_access_token' !== $uri) {
throw new OAuth2ServerException(OAuth2::HTTP_BAD_REQUEST, OAuth2::ERROR_UNSUPPORTED_GRANT_TYPE);
throw new OAuth2ServerException(Response::HTTP_BAD_REQUEST, OAuth2::ERROR_UNSUPPORTED_GRANT_TYPE);
}

if (!isset($inputData['fb_access_token'])) {
Expand Down

0 comments on commit a41fef6

Please sign in to comment.