Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing HTTP status code definition #105

Merged
merged 7 commits into from
Jan 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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