diff --git a/src/Grant/AuthCodeGrant.php b/src/Grant/AuthCodeGrant.php index a3ab8a32..20d5041b 100644 --- a/src/Grant/AuthCodeGrant.php +++ b/src/Grant/AuthCodeGrant.php @@ -200,27 +200,6 @@ class AuthCodeGrant extends AbstractAuthorizeGrant return 'authorization_code'; } - /** - * Fetch the client_id parameter from the query string. - * - * @return string|null - * @throws OAuthServerException - */ - protected function getClientIdFromRequest($request) - { - $clientId = $this->getQueryStringParameter( - 'client_id', - $request, - $this->getServerParameter('PHP_AUTH_USER', $request) - ); - - if (is_null($clientId)) { - throw OAuthServerException::invalidRequest('client_id'); - } - - return $clientId; - } - /** * {@inheritdoc} */ @@ -229,7 +208,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant return ( array_key_exists('response_type', $request->getQueryParams()) && $request->getQueryParams()['response_type'] === 'code' - && $this->getClientIdFromRequest($request) !== null + && isset($request->getQueryParams()['client_id']) ); } @@ -238,7 +217,14 @@ class AuthCodeGrant extends AbstractAuthorizeGrant */ public function validateAuthorizationRequest(ServerRequestInterface $request) { - $clientId = $this->getClientIdFromRequest($request); + $clientId = $this->getQueryStringParameter( + 'client_id', + $request, + $this->getServerParameter('PHP_AUTH_USER', $request) + ); + if (is_null($clientId)) { + throw OAuthServerException::invalidRequest('client_id'); + } $client = $this->clientRepository->getClientEntity( $clientId, diff --git a/tests/Grant/AuthCodeGrantTest.php b/tests/Grant/AuthCodeGrantTest.php index e23bb06b..6a319234 100644 --- a/tests/Grant/AuthCodeGrantTest.php +++ b/tests/Grant/AuthCodeGrantTest.php @@ -335,7 +335,7 @@ class AuthCodeGrantTest extends TestCase ] ); - $grant->canRespondToAuthorizationRequest($request); + $grant->validateAuthorizationRequest($request); } /**