mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-27 07:20:18 +05:30
Merge pull request #892 from Sephster/fix-issue-837
Revert fix for client ID exception
This commit is contained in:
commit
7e07033b10
@ -201,12 +201,21 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch the client_id parameter from the query string.
|
* {@inheritdoc}
|
||||||
*
|
|
||||||
* @return string|null
|
|
||||||
* @throws OAuthServerException
|
|
||||||
*/
|
*/
|
||||||
protected function getClientIdFromRequest($request)
|
public function canRespondToAuthorizationRequest(ServerRequestInterface $request)
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
array_key_exists('response_type', $request->getQueryParams())
|
||||||
|
&& $request->getQueryParams()['response_type'] === 'code'
|
||||||
|
&& isset($request->getQueryParams()['client_id'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function validateAuthorizationRequest(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
$clientId = $this->getQueryStringParameter(
|
$clientId = $this->getQueryStringParameter(
|
||||||
'client_id',
|
'client_id',
|
||||||
@ -218,28 +227,6 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
|
|||||||
throw OAuthServerException::invalidRequest('client_id');
|
throw OAuthServerException::invalidRequest('client_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $clientId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function canRespondToAuthorizationRequest(ServerRequestInterface $request)
|
|
||||||
{
|
|
||||||
return (
|
|
||||||
array_key_exists('response_type', $request->getQueryParams())
|
|
||||||
&& $request->getQueryParams()['response_type'] === 'code'
|
|
||||||
&& $this->getClientIdFromRequest($request) !== null
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function validateAuthorizationRequest(ServerRequestInterface $request)
|
|
||||||
{
|
|
||||||
$clientId = $this->getClientIdFromRequest($request);
|
|
||||||
|
|
||||||
$client = $this->clientRepository->getClientEntity(
|
$client = $this->clientRepository->getClientEntity(
|
||||||
$clientId,
|
$clientId,
|
||||||
$this->getIdentifier(),
|
$this->getIdentifier(),
|
||||||
@ -253,6 +240,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
|
|||||||
}
|
}
|
||||||
|
|
||||||
$redirectUri = $this->getQueryStringParameter('redirect_uri', $request);
|
$redirectUri = $this->getQueryStringParameter('redirect_uri', $request);
|
||||||
|
|
||||||
if ($redirectUri !== null) {
|
if ($redirectUri !== null) {
|
||||||
if (
|
if (
|
||||||
is_string($client->getRedirectUri())
|
is_string($client->getRedirectUri())
|
||||||
@ -298,6 +286,7 @@ class AuthCodeGrant extends AbstractAuthorizeGrant
|
|||||||
}
|
}
|
||||||
|
|
||||||
$codeChallengeMethod = $this->getQueryStringParameter('code_challenge_method', $request, 'plain');
|
$codeChallengeMethod = $this->getQueryStringParameter('code_challenge_method', $request, 'plain');
|
||||||
|
|
||||||
if (in_array($codeChallengeMethod, ['plain', 'S256'], true) === false) {
|
if (in_array($codeChallengeMethod, ['plain', 'S256'], true) === false) {
|
||||||
throw OAuthServerException::invalidRequest(
|
throw OAuthServerException::invalidRequest(
|
||||||
'code_challenge_method',
|
'code_challenge_method',
|
||||||
|
@ -335,7 +335,7 @@ class AuthCodeGrantTest extends TestCase
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
$grant->canRespondToAuthorizationRequest($request);
|
$grant->validateAuthorizationRequest($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user