Skip to content

Commit

Permalink
Merge pull request #657 from thephpleague/analysis-86wPg4
Browse files Browse the repository at this point in the history
Applied fixes from StyleCI
  • Loading branch information
alexbilbie committed Sep 13, 2016
2 parents d7df2f7 + 11ccc30 commit 32cde01
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 14 deletions.
3 changes: 1 addition & 2 deletions examples/public/api.php
Expand Up @@ -31,7 +31,6 @@
$app->get(
'/users',
function (ServerRequestInterface $request, ResponseInterface $response) use ($app) {

$users = [
[
'id' => 123,
Expand Down Expand Up @@ -70,4 +69,4 @@ function (ServerRequestInterface $request, ResponseInterface $response) use ($ap
}
);

$app->run();
$app->run();
4 changes: 2 additions & 2 deletions examples/public/client_credentials.php
Expand Up @@ -30,9 +30,9 @@
$accessTokenRepository = new AccessTokenRepository(); // instance of AccessTokenRepositoryInterface

// Path to public and private keys
$privateKey = 'file://'.__DIR__.'/../private.key';
$privateKey = 'file://' . __DIR__ . '/../private.key';
//$privateKey = new CryptKey('file://path/to/private.key', 'passphrase'); // if private key has a pass phrase
$publicKey = 'file://'.__DIR__.'/../public.key';
$publicKey = 'file://' . __DIR__ . '/../public.key';

// Setup the authorization server
$server = new AuthorizationServer(
Expand Down
8 changes: 3 additions & 5 deletions examples/public/password.php
Expand Up @@ -23,8 +23,8 @@
new ClientRepository(), // instance of ClientRepositoryInterface
new AccessTokenRepository(), // instance of AccessTokenRepositoryInterface
new ScopeRepository(), // instance of ScopeRepositoryInterface
'file://'.__DIR__.'/../private.key', // path to private key
'file://'.__DIR__.'/../public.key' // path to public key
'file://' . __DIR__ . '/../private.key', // path to private key
'file://' . __DIR__ . '/../public.key' // path to public key
);

$grant = new PasswordGrant(
Expand Down Expand Up @@ -54,19 +54,17 @@ function (ServerRequestInterface $request, ResponseInterface $response) use ($ap

// Try to respond to the access token request
return $server->respondToAccessTokenRequest($request, $response);

} catch (OAuthServerException $exception) {

// All instances of OAuthServerException can be converted to a PSR-7 response
return $exception->generateHttpResponse($response);

} catch (\Exception $exception) {

// Catch unexpected exceptions
$body = $response->getBody();
$body->write($exception->getMessage());
return $response->withStatus(500)->withBody($body);

return $response->withStatus(500)->withBody($body);
}
}
);
Expand Down
2 changes: 1 addition & 1 deletion examples/src/Repositories/ScopeRepository.php
Expand Up @@ -54,7 +54,7 @@ public function finalizeScopes(
$scope->setIdentifier('email');
$scopes[] = $scope;
}

return $scopes;
}
}
2 changes: 1 addition & 1 deletion src/AuthorizationValidators/BearerTokenValidator.php
Expand Up @@ -75,7 +75,7 @@ public function validateAuthorization(ServerRequestInterface $request)
} catch (\InvalidArgumentException $exception) {
// JWT couldn't be parsed so return the request as is
throw OAuthServerException::accessDenied($exception->getMessage());
} catch(\RuntimeException $exception){
} catch (\RuntimeException $exception) {
//JWR couldn't be parsed so return the request as is
throw OAuthServerException::accessDenied('Error while decoding to JSON');
}
Expand Down
Expand Up @@ -9,7 +9,6 @@

namespace League\OAuth2\Server\Exception;


class UniqueTokenIdentifierConstraintViolationException extends OAuthServerException
{
public static function create()
Expand Down
3 changes: 3 additions & 0 deletions src/Grant/AbstractGrant.php
Expand Up @@ -345,6 +345,7 @@ protected function issueAccessToken(
$accessToken->setIdentifier($this->generateUniqueIdentifier());
try {
$this->accessTokenRepository->persistNewAccessToken($accessToken);

return $accessToken;
} catch (UniqueTokenIdentifierConstraintViolationException $e) {
if ($maxGenerationAttempts === 0) {
Expand Down Expand Up @@ -391,6 +392,7 @@ protected function issueAuthCode(
$authCode->setIdentifier($this->generateUniqueIdentifier());
try {
$this->authCodeRepository->persistNewAuthCode($authCode);

return $authCode;
} catch (UniqueTokenIdentifierConstraintViolationException $e) {
if ($maxGenerationAttempts === 0) {
Expand Down Expand Up @@ -420,6 +422,7 @@ protected function issueRefreshToken(AccessTokenEntityInterface $accessToken)
$refreshToken->setIdentifier($this->generateUniqueIdentifier());
try {
$this->refreshTokenRepository->persistNewRefreshToken($refreshToken);

return $refreshToken;
} catch (UniqueTokenIdentifierConstraintViolationException $e) {
if ($maxGenerationAttempts === 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/Grant/ImplicitGrant.php
Expand Up @@ -150,7 +150,7 @@ public function validateAuthorizationRequest(ServerRequestInterface $request)
? $client->getRedirectUri()[0]
: $client->getRedirectUri()
);

// Finalize the requested scopes
$scopes = $this->scopeRepository->finalizeScopes(
$scopes,
Expand Down
2 changes: 2 additions & 0 deletions src/RequestTypes/AuthorizationRequest.php
Expand Up @@ -66,12 +66,14 @@ class AuthorizationRequest

/**
* The code challenge (if provided)
*
* @var string
*/
protected $codeChallenge;

/**
* The code challenge method (if provided)
*
* @var string
*/
protected $codeChallengeMethod;
Expand Down
1 change: 1 addition & 0 deletions src/ResponseTypes/BearerTokenResponse.php
Expand Up @@ -68,6 +68,7 @@ public function generateHttpResponse(ResponseInterface $response)
* this class rather than the default.
*
* @param AccessTokenEntityInterface $accessToken
*
* @return array
*/
protected function getExtraParams(AccessTokenEntityInterface $accessToken)
Expand Down
1 change: 0 additions & 1 deletion tests/Grant/AuthCodeGrantTest.php
Expand Up @@ -137,7 +137,6 @@ public function testValidateAuthorizationRequestRedirectUriArray()
$this->assertTrue($grant->validateAuthorizationRequest($request) instanceof AuthorizationRequest);
}


public function testValidateAuthorizationRequestCodeChallenge()
{
$client = new ClientEntity();
Expand Down

0 comments on commit 32cde01

Please sign in to comment.