src/OAuth2/Controller/ResourceController.php
public function verifyResourceRequest(RequestInterface $request, ResponseInterface $response, $scope = null)
    {
        $token = $this->getAccessTokenData($request, $response);

        // Check if we have token data
        if (is_null($token)) {
            return false;
        }

        /**
         * Check scope, if provided
         * If token doesn't have a scope, it's null/empty, or it's insufficient, then throw 403
         * @see http://tools.ietf.org/html/rfc6750#section-3.1
         */
        if ($scope && (!isset($token["scope"]) || !$token["scope"] || !$this->scopeUtil->checkScope($scope, $token["scope"]))) {
            $response->setError(403, 'insufficient_scope', 'The request requires higher privileges than provided by the access token');
            $response->addHttpHeaders(array(
                'WWW-Authenticate' => sprintf('%s realm="%s", scope="%s", error="%s", error_description="%s"',
                    $this->tokenType->getTokenType(),
                    $this->config['www_realm'],
                    $scope,
                    $response->getParameter('error'),
                    $response->getParameter('error_description')
                )
            ));

            return false;
        }

        // allow retrieval of the token
        $this->token = $token;

        return (bool) $token;
    }
public function verifyResourceRequest(RequestInterface $request, ResponseInterface $response, $scope = null)
    {
        $token = $this->getAccessTokenData($request, $response);

        // Check if we have token data
        if (is_null($token)) {
            return false;
        }

        /**
         * Check scope, if provided
         * If token doesn't have a scope, it's null/empty, or it's insufficient, then throw 403
         * @see http://tools.ietf.org/html/rfc6750#section-3.1
         */
        if ($scope && (!isset($token["scope"]) || !$token["scope"] || !$this->scopeUtil->checkScope($scope, $token["scope"]))) {
            $response->setError(403, 'insufficient_scope', 'The request requires higher privileges than provided by the access token');
            $response->addHttpHeaders(array(
                'WWW-Authenticate' => sprintf('%s realm="%s", scope="%s", error="%s", error_description="%s"',
                    $this->tokenType->getTokenType(),
                    $this->config['www_realm'],
                    $scope,
                    $response->getParameter('error'),
                    $response->getParameter('error_description')
                )
            ));

            return false;
        }

        // allow retrieval of the token
        $this->token = $token;

        return (bool) $token;
    }
public function verifyResourceRequest ( RequestInterface $ request , ResponseInterface $ response , $ scope = null ) { $ token = $ this -> getAccessTokenData ( $ request , $ response ) ; // Check if we have token data if ( is_null ( $ token ) ) { return false ; } /**
         * Check scope, if provided
         * If token doesn't have a scope, it's null/empty, or it's insufficient, then throw 403
         * @see http://tools.ietf.org/html/rfc6750#section-3.1
         */ if ( $ scope && ( ! isset ( $ token [ "scope" ] ) || ! $ token [ "scope" ] || ! $ this -> scopeUtil -> checkScope ( $ scope , $ token [ "scope" ] ) ) ) { $ response -> setError ( 403 , 'insufficient_scope' , 'The request requires higher privileges than provided by the access token' ) ; $ response -> addHttpHeaders ( array ( 'WWW-Authenticate' => sprintf ( '%s realm="%s", scope="%s", error="%s", error_description="%s"' , $ this -> tokenType -> getTokenType ( ) , $ this -> config [ 'www_realm' ] , $ scope , $ response -> getParameter ( 'error' ) , $ response -> getParameter ( 'error_description' ) ) ) ) ; return false ; } // allow retrieval of the token $ this -> token = $ token ; return ( bool ) $ token ; }
Verify the resource request

@param RequestInterface  $request
@param ResponseInterface $response
@param null              $scope
@return bool
Verify the resource request