src/Grant/AbstractGrant.php
public function validateScopes($scopeParam = '', ClientEntity $client, $redirectUri = null)
    {
        $scopesList = explode($this->server->getScopeDelimiter(), $scopeParam);

        for ($i = 0; $i < count($scopesList); $i++) {
            $scopesList[$i] = trim($scopesList[$i]);
            if ($scopesList[$i] === '') {
                unset($scopesList[$i]); // Remove any junk scopes
            }
        }

        if (
            $this->server->scopeParamRequired() === true
            && $this->server->getDefaultScope() === null
            && count($scopesList) === 0
        ) {
            throw new Exception\InvalidRequestException('scope');
        } elseif (count($scopesList) === 0 && $this->server->getDefaultScope() !== null) {
            if (is_array($this->server->getDefaultScope())) {
                $scopesList = $this->server->getDefaultScope();
            } else {
                $scopesList = [0 => $this->server->getDefaultScope()];
            }
        }

        $scopes = [];

        foreach ($scopesList as $scopeItem) {
            $scope = $this->server->getScopeStorage()->get(
                $scopeItem,
                $this->getIdentifier(),
                $client->getId()
            );

            if (($scope instanceof ScopeEntity) === false) {
                throw new Exception\InvalidScopeException($scopeItem, $redirectUri);
            }

            $scopes[$scope->getId()] = $scope;
        }

        return $scopes;
    }
public function validateScopes($scopeParam = '', ClientEntity $client, $redirectUri = null)
    {
        $scopesList = explode($this->server->getScopeDelimiter(), $scopeParam);

        for ($i = 0; $i < count($scopesList); $i++) {
            $scopesList[$i] = trim($scopesList[$i]);
            if ($scopesList[$i] === '') {
                unset($scopesList[$i]); // Remove any junk scopes
            }
        }

        if (
            $this->server->scopeParamRequired() === true
            && $this->server->getDefaultScope() === null
            && count($scopesList) === 0
        ) {
            throw new Exception\InvalidRequestException('scope');
        } elseif (count($scopesList) === 0 && $this->server->getDefaultScope() !== null) {
            if (is_array($this->server->getDefaultScope())) {
                $scopesList = $this->server->getDefaultScope();
            } else {
                $scopesList = [0 => $this->server->getDefaultScope()];
            }
        }

        $scopes = [];

        foreach ($scopesList as $scopeItem) {
            $scope = $this->server->getScopeStorage()->get(
                $scopeItem,
                $this->getIdentifier(),
                $client->getId()
            );

            if (($scope instanceof ScopeEntity) === false) {
                throw new Exception\InvalidScopeException($scopeItem, $redirectUri);
            }

            $scopes[$scope->getId()] = $scope;
        }

        return $scopes;
    }
public function validateScopes ( $ scopeParam = '' , ClientEntity $ client , $ redirectUri = null ) { $ scopesList = explode ( $ this -> server -> getScopeDelimiter ( ) , $ scopeParam ) ; for ( $ i = 0 ; $ i < count ( $ scopesList ) ; $ i ++ ) { $ scopesList [ $ i ] = trim ( $ scopesList [ $ i ] ) ; if ( $ scopesList [ $ i ] === '' ) { unset ( $ scopesList [ $ i ] ) ; // Remove any junk scopes } } if ( $ this -> server -> scopeParamRequired ( ) === true && $ this -> server -> getDefaultScope ( ) === null && count ( $ scopesList ) === 0 ) { throw new Exception \ InvalidRequestException ( 'scope' ) ; } elseif ( count ( $ scopesList ) === 0 && $ this -> server -> getDefaultScope ( ) !== null ) { if ( is_array ( $ this -> server -> getDefaultScope ( ) ) ) { $ scopesList = $ this -> server -> getDefaultScope ( ) ; } else { $ scopesList = [ 0 => $ this -> server -> getDefaultScope ( ) ] ; } } $ scopes = [ ] ; foreach ( $ scopesList as $ scopeItem ) { $ scope = $ this -> server -> getScopeStorage ( ) -> get ( $ scopeItem , $ this -> getIdentifier ( ) , $ client -> getId ( ) ) ; if ( ( $ scope instanceof ScopeEntity ) === false ) { throw new Exception \ InvalidScopeException ( $ scopeItem , $ redirectUri ) ; } $ scopes [ $ scope -> getId ( ) ] = $ scope ; } return $ scopes ; }
Given a list of scopes, validate them and return an array of Scope entities

@param string                                    $scopeParam  A string of scopes (e.g. "profile email birthday")
@param \League\OAuth2\Server\Entity\ClientEntity $client      Client entity
@param string|null                               $redirectUri The redirect URI to return the user to

@return \League\OAuth2\Server\Entity\ScopeEntity[]

@throws \League\OAuth2\Server\Exception\InvalidScopeException If scope is invalid, or no scopes passed when required
@throws
Given a list of scopes validate them and return an array of Scope entities