diff --git a/examples/public/auth_code.php b/examples/public/auth_code.php index d15a1561..998101dc 100644 --- a/examples/public/auth_code.php +++ b/examples/public/auth_code.php @@ -13,7 +13,7 @@ use Slim\App; use Slim\Http\Request; use Slim\Http\Response; -include __DIR__.'/../vendor/autoload.php'; +include __DIR__ . '/../vendor/autoload.php'; // App $app = new App([ @@ -27,8 +27,8 @@ $app = new App([ $refreshTokenRepository = new RefreshTokenRepository(); $authCodeRepository = new AuthCodeRepository(); - $privateKeyPath = 'file://'.__DIR__.'/../private.key'; - $publicKeyPath = 'file://'.__DIR__.'/../public.key'; + $privateKeyPath = 'file://' . __DIR__ . '/../private.key'; + $publicKeyPath = 'file://' . __DIR__ . '/../public.key'; // Setup the authorization server $server = new Server( diff --git a/examples/public/client_credentials.php b/examples/public/client_credentials.php index 48ee0b6f..a36207ee 100644 --- a/examples/public/client_credentials.php +++ b/examples/public/client_credentials.php @@ -10,7 +10,7 @@ use Slim\App; use Slim\Http\Request; use Slim\Http\Response; -include __DIR__.'/../vendor/autoload.php'; +include __DIR__ . '/../vendor/autoload.php'; // App $app = new App([ @@ -21,8 +21,8 @@ $app = new App([ $scopeRepository = new ScopeRepository(); $accessTokenRepository = new AccessTokenRepository(); - $privateKeyPath = 'file://'.__DIR__.'/../private.key'; - $publicKeyPath = 'file://'.__DIR__.'/../public.key'; + $privateKeyPath = 'file://' . __DIR__ . '/../private.key'; + $publicKeyPath = 'file://' . __DIR__ . '/../public.key'; // Setup the authorization server $server = new Server( diff --git a/examples/public/middleware_authentication.php b/examples/public/middleware_authentication.php index 27f03c5a..f5790687 100644 --- a/examples/public/middleware_authentication.php +++ b/examples/public/middleware_authentication.php @@ -11,7 +11,7 @@ use OAuth2ServerExamples\Repositories\ScopeRepository; use OAuth2ServerExamples\Repositories\UserRepository; use Slim\App; -include __DIR__.'/../vendor/autoload.php'; +include __DIR__ . '/../vendor/autoload.php'; // App $app = new App([ @@ -27,8 +27,8 @@ $app = new App([ $userRepository = new UserRepository(); $refreshTokenRepository = new RefreshTokenRepository(); - $privateKeyPath = 'file://'.__DIR__.'/../private.key'; - $publicKeyPath = 'file://'.__DIR__.'/../public.key'; + $privateKeyPath = 'file://' . __DIR__ . '/../private.key'; + $publicKeyPath = 'file://' . __DIR__ . '/../public.key'; // Setup the authorization server $server = new Server( diff --git a/examples/public/password.php b/examples/public/password.php index 4c0548b4..aa4f75dc 100644 --- a/examples/public/password.php +++ b/examples/public/password.php @@ -12,7 +12,7 @@ use Slim\App; use Slim\Http\Request; use Slim\Http\Response; -include __DIR__.'/../vendor/autoload.php'; +include __DIR__ . '/../vendor/autoload.php'; // App $app = new App([ @@ -25,8 +25,8 @@ $app = new App([ $userRepository = new UserRepository(); $refreshTokenRepository = new RefreshTokenRepository(); - $privateKeyPath = 'file://'.__DIR__.'/../private.key'; - $publicKeyPath = 'file://'.__DIR__.'/../public.key'; + $privateKeyPath = 'file://' . __DIR__ . '/../private.key'; + $publicKeyPath = 'file://' . __DIR__ . '/../public.key'; // Setup the authorization server $server = new Server( diff --git a/examples/public/protected_api.php b/examples/public/protected_api.php index 35b829ae..6e502fba 100644 --- a/examples/public/protected_api.php +++ b/examples/public/protected_api.php @@ -9,7 +9,7 @@ use Slim\App; use Slim\Http\Request; use Slim\Http\Response; -include __DIR__.'/../vendor/autoload.php'; +include __DIR__ . '/../vendor/autoload.php'; // App $app = new App([ @@ -23,8 +23,8 @@ $app = new App([ $scopeRepository = new ScopeRepository(); $accessTokenRepository = new AccessTokenRepository(); - $privateKeyPath = 'file://'.__DIR__.'/../private.key'; - $publicKeyPath = 'file://'.__DIR__.'/../public.key'; + $privateKeyPath = 'file://' . __DIR__ . '/../private.key'; + $publicKeyPath = 'file://' . __DIR__ . '/../public.key'; // Setup the authorization server $server = new Server( diff --git a/examples/public/refresh_token.php b/examples/public/refresh_token.php index 6ecf5122..bbec33e3 100644 --- a/examples/public/refresh_token.php +++ b/examples/public/refresh_token.php @@ -11,7 +11,7 @@ use Slim\App; use Slim\Http\Request; use Slim\Http\Response; -include __DIR__.'/../vendor/autoload.php'; +include __DIR__ . '/../vendor/autoload.php'; // App $app = new App([Server::class => function () { @@ -21,8 +21,8 @@ $app = new App([Server::class => function () { $accessTokenRepository = new AccessTokenRepository(); $refreshTokenRepository = new RefreshTokenRepository(); - $privateKeyPath = 'file://'.__DIR__.'/../private.key'; - $publicKeyPath = 'file://'.__DIR__.'/../public.key'; + $privateKeyPath = 'file://' . __DIR__ . '/../private.key'; + $publicKeyPath = 'file://' . __DIR__ . '/../public.key'; // Setup the authorization server $server = new Server( diff --git a/src/Entities/Interfaces/AccessTokenEntityInterface.php b/src/Entities/Interfaces/AccessTokenEntityInterface.php index 2a7ef985..884c0187 100644 --- a/src/Entities/Interfaces/AccessTokenEntityInterface.php +++ b/src/Entities/Interfaces/AccessTokenEntityInterface.php @@ -2,8 +2,6 @@ namespace League\OAuth2\Server\Entities\Interfaces; -use Lcobucci\JWT\Builder; - interface AccessTokenEntityInterface extends TokenInterface { /** diff --git a/src/Exception/OAuthServerException.php b/src/Exception/OAuthServerException.php index 3bd4e934..7b8a1016 100644 --- a/src/Exception/OAuthServerException.php +++ b/src/Exception/OAuthServerException.php @@ -50,6 +50,7 @@ class OAuthServerException extends \Exception /** * Invalid grant type error. + * * @return static */ public static function invalidGrantType() diff --git a/src/Grant/AbstractGrant.php b/src/Grant/AbstractGrant.php index 407ae4db..a7b5fbd1 100644 --- a/src/Grant/AbstractGrant.php +++ b/src/Grant/AbstractGrant.php @@ -16,7 +16,6 @@ use League\Event\Event; use League\OAuth2\Server\Entities\AccessTokenEntity; use League\OAuth2\Server\Entities\AuthCodeEntity; use League\OAuth2\Server\Entities\Interfaces\ClientEntityInterface; -use League\OAuth2\Server\Entities\Interfaces\ScopeEntityInterface; use League\OAuth2\Server\Entities\RefreshTokenEntity; use League\OAuth2\Server\Entities\ScopeEntity; use League\OAuth2\Server\Exception\OAuthServerException; diff --git a/src/Grant/ImplicitGrant.php b/src/Grant/ImplicitGrant.php index 959c69b2..8123550e 100644 --- a/src/Grant/ImplicitGrant.php +++ b/src/Grant/ImplicitGrant.php @@ -2,7 +2,6 @@ namespace League\OAuth2\Server\Grant; -use DateInterval; use League\Event\Event; use League\OAuth2\Server\Entities\Interfaces\ClientEntityInterface; use League\OAuth2\Server\Entities\Interfaces\UserEntityInterface; diff --git a/src/Grant/RefreshTokenGrant.php b/src/Grant/RefreshTokenGrant.php index 19bab077..83ffe5ed 100644 --- a/src/Grant/RefreshTokenGrant.php +++ b/src/Grant/RefreshTokenGrant.php @@ -102,7 +102,7 @@ class RefreshTokenGrant extends AbstractGrant try { $refreshToken = KeyCrypt::decrypt($encryptedRefreshToken, $this->pathToPublicKey); } catch (\LogicException $e) { - throw OAuthServerException::invalidRefreshToken('Cannot parse refresh token: '.$e->getMessage()); + throw OAuthServerException::invalidRefreshToken('Cannot parse refresh token: ' . $e->getMessage()); } $refreshTokenData = json_decode($refreshToken, true); @@ -110,9 +110,9 @@ class RefreshTokenGrant extends AbstractGrant $this->getEmitter()->emit(new Event('refresh_token.client.failed', $request)); throw OAuthServerException::invalidRefreshToken( - 'Token is not linked to client,'. - ' got: '.$clientId. - ' expected: '.$refreshTokenData['client_id'] + 'Token is not linked to client,' . + ' got: ' . $clientId . + ' expected: ' . $refreshTokenData['client_id'] ); } diff --git a/src/ResponseTypes/BearerTokenResponse.php b/src/ResponseTypes/BearerTokenResponse.php index a1da1fe8..fdbe73b0 100644 --- a/src/ResponseTypes/BearerTokenResponse.php +++ b/src/ResponseTypes/BearerTokenResponse.php @@ -10,9 +10,7 @@ */ namespace League\OAuth2\Server\ResponseTypes; -use Lcobucci\JWT\Builder; use Lcobucci\JWT\Parser; -use Lcobucci\JWT\Signer\Key; use Lcobucci\JWT\Signer\Rsa\Sha256; use League\OAuth2\Server\Entities\Interfaces\RefreshTokenEntityInterface; use League\OAuth2\Server\Exception\OAuthServerException; diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index 8ea9bc26..99c00e16 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -1,5 +1,5 @@ wget http://getcomposer.org/composer.phar\n> php composer.phar install\n"); } diff --git a/tests/Grant/AuthCodeGrantTest.php b/tests/Grant/AuthCodeGrantTest.php index d5764843..1508329c 100644 --- a/tests/Grant/AuthCodeGrantTest.php +++ b/tests/Grant/AuthCodeGrantTest.php @@ -7,16 +7,15 @@ use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface; use League\OAuth2\Server\Entities\Interfaces\RefreshTokenEntityInterface; use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\Grant\AuthCodeGrant; +use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface; use League\OAuth2\Server\Repositories\AuthCodeRepositoryInterface; use League\OAuth2\Server\Repositories\ClientRepositoryInterface; use League\OAuth2\Server\Repositories\RefreshTokenRepositoryInterface; -use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface; use League\OAuth2\Server\Repositories\UserRepositoryInterface; use League\OAuth2\Server\Utils\KeyCrypt; use LeagueTests\Stubs\StubResponseType; use LeagueTests\Stubs\UserEntity; use Psr\Http\Message\ResponseInterface; -use Zend\Diactoros\Response; use Zend\Diactoros\ServerRequest; class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase @@ -46,8 +45,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase $request = new ServerRequest( [], - [] - , + [], null, null, 'php://input', @@ -90,8 +88,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase 'HTTP_HOST' => 'auth-server.tld', 'REQUEST_URI' => '/authorize', ], - [] - , + [], null, 'POST', 'php://input', @@ -148,8 +145,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase 'HTTP_HOST' => 'auth-server.tld', 'REQUEST_URI' => '/authorize', ], - [] - , + [], null, 'POST', 'php://input', @@ -211,8 +207,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase 'HTTP_HOST' => 'auth-server.tld', 'REQUEST_URI' => '/authorize', ], - [] - , + [], null, 'POST', 'php://input', @@ -263,8 +258,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase 'HTTP_HOST' => 'auth-server.tld', 'REQUEST_URI' => '/authorize', ], - [] - , + [], null, 'POST', 'php://input', @@ -287,7 +281,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase ); try { - /** @var StubResponseType $response */ + /* @var StubResponseType $response */ $grant->respondToRequest($request, new StubResponseType(), new \DateInterval('PT10M')); } catch (OAuthServerException $e) { $this->assertEquals($e->getMessage(), 'Client authentication failed'); @@ -319,8 +313,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase 'HTTP_HOST' => 'auth-server.tld', 'REQUEST_URI' => '/authorize', ], - [] - , + [], null, 'POST', 'php://input', @@ -334,7 +327,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase [ 'response_type' => 'code', 'client_id' => 'foo', - 'redirect_uri' => 'sdfsdf' + 'redirect_uri' => 'sdfsdf', ], [ 'username' => 'alex', @@ -344,7 +337,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase ); try { - /** @var StubResponseType $response */ + /* @var StubResponseType $response */ $grant->respondToRequest($request, new StubResponseType(), new \DateInterval('PT10M')); } catch (OAuthServerException $e) { $this->assertEquals($e->getMessage(), 'Client authentication failed'); @@ -383,8 +376,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase 'HTTP_HOST' => 'auth-server.tld', 'REQUEST_URI' => '/authorize', ], - [] - , + [], null, 'POST', 'php://input', @@ -436,8 +428,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase 'HTTP_HOST' => 'auth-server.tld', 'REQUEST_URI' => '/authorize', ], - [] - , + [], null, 'POST', 'php://input', @@ -491,8 +482,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase 'HTTP_HOST' => 'auth-server.tld', 'REQUEST_URI' => '/authorize', ], - [] - , + [], null, 'POST', 'php://input', @@ -547,8 +537,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase 'HTTP_HOST' => 'auth-server.tld', 'REQUEST_URI' => '/authorize', ], - [] - , + [], null, 'POST', 'php://input', @@ -607,8 +596,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase $request = new ServerRequest( [], - [] - , + [], null, 'POST', 'php://input', @@ -667,8 +655,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase $request = new ServerRequest( [], - [] - , + [], null, 'POST', 'php://input', @@ -680,7 +667,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase ] ); - /** @var StubResponseType $response */ + /* @var StubResponseType $response */ $grant->respondToRequest($request, new StubResponseType(), new \DateInterval('PT10M')); } @@ -714,8 +701,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase $request = new ServerRequest( [], - [] - , + [], null, 'POST', 'php://input', @@ -730,7 +716,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase ] ); - /** @var StubResponseType $response */ + /* @var StubResponseType $response */ $grant->respondToRequest($request, new StubResponseType(), new \DateInterval('PT10M')); } @@ -766,8 +752,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase $request = new ServerRequest( [], - [] - , + [], null, 'POST', 'php://input', @@ -795,7 +780,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase ); try { - /** @var StubResponseType $response */ + /* @var StubResponseType $response */ $grant->respondToRequest($request, new StubResponseType(), new \DateInterval('PT10M')); } catch (OAuthServerException $e) { $this->assertEquals($e->getHint(), 'Authorization code has expired'); @@ -837,8 +822,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase $request = new ServerRequest( [], - [] - , + [], null, 'POST', 'php://input', @@ -866,7 +850,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase ); try { - /** @var StubResponseType $response */ + /* @var StubResponseType $response */ $grant->respondToRequest($request, new StubResponseType(), new \DateInterval('PT10M')); } catch (OAuthServerException $e) { $this->assertEquals($e->getHint(), 'Authorization code has been revoked'); @@ -905,8 +889,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase $request = new ServerRequest( [], - [] - , + [], null, 'POST', 'php://input', @@ -934,7 +917,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase ); try { - /** @var StubResponseType $response */ + /* @var StubResponseType $response */ $grant->respondToRequest($request, new StubResponseType(), new \DateInterval('PT10M')); } catch (OAuthServerException $e) { $this->assertEquals($e->getHint(), 'Authorization code was not issued to this client'); @@ -973,8 +956,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase $request = new ServerRequest( [], - [] - , + [], null, 'POST', 'php://input', @@ -990,7 +972,7 @@ class AuthCodeGrantTest extends \PHPUnit_Framework_TestCase ); try { - /** @var StubResponseType $response */ + /* @var StubResponseType $response */ $grant->respondToRequest($request, new StubResponseType(), new \DateInterval('PT10M')); } catch (OAuthServerException $e) { $this->assertEquals($e->getHint(), 'Cannot decrypt the authorization code'); diff --git a/tests/Grant/PasswordGrantTest.php b/tests/Grant/PasswordGrantTest.php index 096f374e..e4f9e3a9 100644 --- a/tests/Grant/PasswordGrantTest.php +++ b/tests/Grant/PasswordGrantTest.php @@ -5,7 +5,6 @@ namespace LeagueTests\Grant; use League\OAuth2\Server\Entities\ClientEntity; use League\OAuth2\Server\Entities\Interfaces\AccessTokenEntityInterface; use League\OAuth2\Server\Entities\Interfaces\RefreshTokenEntityInterface; -use League\OAuth2\Server\Exception\OAuthServerException; use League\OAuth2\Server\Grant\PasswordGrant; use League\OAuth2\Server\Repositories\AccessTokenRepositoryInterface; use League\OAuth2\Server\Repositories\ClientRepositoryInterface; diff --git a/tests/Utils/KeyCryptTest.php b/tests/Utils/KeyCryptTest.php index 9720dbd3..3fa1f17c 100644 --- a/tests/Utils/KeyCryptTest.php +++ b/tests/Utils/KeyCryptTest.php @@ -9,8 +9,8 @@ class KeyCryptTest extends \PHPUnit_Framework_TestCase public function testEncryptDecrypt() { $payload = 'alex loves whisky'; - $encrypted = KeyCrypt::encrypt($payload, 'file://'.__DIR__.'/private.key'); - $plainText = KeyCrypt::decrypt($encrypted, 'file://'.__DIR__.'/public.key'); + $encrypted = KeyCrypt::encrypt($payload, 'file://' . __DIR__ . '/private.key'); + $plainText = KeyCrypt::decrypt($encrypted, 'file://' . __DIR__ . '/public.key'); $this->assertNotEquals($payload, $encrypted); $this->assertEquals($payload, $plainText); @@ -21,7 +21,7 @@ class KeyCryptTest extends \PHPUnit_Framework_TestCase */ public function testBadPrivateKey() { - KeyCrypt::encrypt('', 'file://'.__DIR__.'/public.key'); + KeyCrypt::encrypt('', 'file://' . __DIR__ . '/public.key'); } /** @@ -29,6 +29,6 @@ class KeyCryptTest extends \PHPUnit_Framework_TestCase */ public function testBadPublicKey() { - KeyCrypt::decrypt('', 'file://'.__DIR__.'/private.key'); + KeyCrypt::decrypt('', 'file://' . __DIR__ . '/private.key'); } }