From 57323f38f790f51c7527c37d42791341188b2367 Mon Sep 17 00:00:00 2001 From: Pierre Rineau Date: Wed, 13 Jul 2016 12:03:05 +0200 Subject: [PATCH] while(array_shift()) makes the AuthorizationServer class configuration mutable --- src/AuthorizationServer.php | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/AuthorizationServer.php b/src/AuthorizationServer.php index 2cc48ab2..0517124a 100644 --- a/src/AuthorizationServer.php +++ b/src/AuthorizationServer.php @@ -135,14 +135,9 @@ class AuthorizationServer implements EmitterAwareInterface */ public function validateAuthorizationRequest(ServerRequestInterface $request) { - $authRequest = null; - $enabledGrantTypes = $this->enabledGrantTypes; - while ($authRequest === null && $grantType = array_shift($enabledGrantTypes)) { - /** @var \League\OAuth2\Server\Grant\GrantTypeInterface $grantType */ + foreach ($this->enabledGrantTypes as $grantType) { if ($grantType->canRespondToAuthorizationRequest($request)) { - $authRequest = $grantType->validateAuthorizationRequest($request); - - return $authRequest; + return $grantType->validateAuthorizationRequest($request); } } @@ -176,20 +171,18 @@ class AuthorizationServer implements EmitterAwareInterface */ public function respondToAccessTokenRequest(ServerRequestInterface $request, ResponseInterface $response) { - $tokenResponse = null; - while ($tokenResponse === null && $grantType = array_shift($this->enabledGrantTypes)) { - /** @var \League\OAuth2\Server\Grant\GrantTypeInterface $grantType */ + foreach ($this->enabledGrantTypes as $grantType) { if ($grantType->canRespondToAccessTokenRequest($request)) { $tokenResponse = $grantType->respondToAccessTokenRequest( $request, $this->getResponseType(), $this->grantTypeAccessTokenTTL[$grantType->getIdentifier()] ); - } - } - if ($tokenResponse instanceof ResponseTypeInterface) { - return $tokenResponse->generateHttpResponse($response); + if ($tokenResponse instanceof ResponseTypeInterface) { + return $tokenResponse->generateHttpResponse($response); + } + } } throw OAuthServerException::unsupportedGrantType();