protected function checkScope(Authorization &$authorization) { try { $scope = $this->getScopeManager()->checkScopePolicy($authorization->getClient(), $authorization->getScope()); $authorization->setScope($scope); } catch (BaseExceptionInterface $e) { throw $e; } catch (\Exception $e) { throw $this->getExceptionManager()->getException(ExceptionManagerInterface::BAD_REQUEST, $e->getMessage()); } $availableScopes = $this->getScopeManager()->getAvailableScopes($authorization->getClient()); if (!$this->getScopeManager()->checkScopes($scope, $availableScopes)) { throw $this->getExceptionManager()->getException(ExceptionManagerInterface::BAD_REQUEST, ExceptionManagerInterface::INVALID_SCOPE, 'An unsupported scope was requested. Available scopes for the client are [' . implode(',', $availableScopes) . ']'); } }
/** * @param array $params * @param \OAuth2\Endpoint\Authorization $authorization */ private function populateScope(array $params, Authorization &$authorization) { if (!isset($params['scope'])) { return; } $scope = $this->getScopeManager()->convertToScope($params['scope']); $authorization->setScope($scope); }