mirror of
https://github.com/elyby/oauth2-server.git
synced 2024-12-23 05:29:52 +05:30
while(array_shift()) makes the AuthorizationServer class configuration mutable
This commit is contained in:
parent
46cd448a47
commit
57323f38f7
@ -135,14 +135,9 @@ class AuthorizationServer implements EmitterAwareInterface
|
|||||||
*/
|
*/
|
||||||
public function validateAuthorizationRequest(ServerRequestInterface $request)
|
public function validateAuthorizationRequest(ServerRequestInterface $request)
|
||||||
{
|
{
|
||||||
$authRequest = null;
|
foreach ($this->enabledGrantTypes as $grantType) {
|
||||||
$enabledGrantTypes = $this->enabledGrantTypes;
|
|
||||||
while ($authRequest === null && $grantType = array_shift($enabledGrantTypes)) {
|
|
||||||
/** @var \League\OAuth2\Server\Grant\GrantTypeInterface $grantType */
|
|
||||||
if ($grantType->canRespondToAuthorizationRequest($request)) {
|
if ($grantType->canRespondToAuthorizationRequest($request)) {
|
||||||
$authRequest = $grantType->validateAuthorizationRequest($request);
|
return $grantType->validateAuthorizationRequest($request);
|
||||||
|
|
||||||
return $authRequest;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,20 +171,18 @@ class AuthorizationServer implements EmitterAwareInterface
|
|||||||
*/
|
*/
|
||||||
public function respondToAccessTokenRequest(ServerRequestInterface $request, ResponseInterface $response)
|
public function respondToAccessTokenRequest(ServerRequestInterface $request, ResponseInterface $response)
|
||||||
{
|
{
|
||||||
$tokenResponse = null;
|
foreach ($this->enabledGrantTypes as $grantType) {
|
||||||
while ($tokenResponse === null && $grantType = array_shift($this->enabledGrantTypes)) {
|
|
||||||
/** @var \League\OAuth2\Server\Grant\GrantTypeInterface $grantType */
|
|
||||||
if ($grantType->canRespondToAccessTokenRequest($request)) {
|
if ($grantType->canRespondToAccessTokenRequest($request)) {
|
||||||
$tokenResponse = $grantType->respondToAccessTokenRequest(
|
$tokenResponse = $grantType->respondToAccessTokenRequest(
|
||||||
$request,
|
$request,
|
||||||
$this->getResponseType(),
|
$this->getResponseType(),
|
||||||
$this->grantTypeAccessTokenTTL[$grantType->getIdentifier()]
|
$this->grantTypeAccessTokenTTL[$grantType->getIdentifier()]
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($tokenResponse instanceof ResponseTypeInterface) {
|
if ($tokenResponse instanceof ResponseTypeInterface) {
|
||||||
return $tokenResponse->generateHttpResponse($response);
|
return $tokenResponse->generateHttpResponse($response);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw OAuthServerException::unsupportedGrantType();
|
throw OAuthServerException::unsupportedGrantType();
|
||||||
|
Loading…
Reference in New Issue
Block a user