/**
  * Helper method to verify a resource request, allowing return early on success cases
  *
  * @param array $scopes Scopes required for authorization
  *
  * @return boolean True if the request is verified, otherwise false
  */
 private function verify(array $scopes = [null])
 {
     foreach ($scopes as $scope) {
         if (is_array($scope)) {
             $scope = implode(' ', $scope);
         }
         if ($this->server->verifyResourceRequest(MessageBridge::newOauth2Request($this->app->request()), null, $scope)) {
             return true;
         }
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * Call this class as a function.
  *
  * @return void
  */
 public function __invoke()
 {
     $request = MessageBridge::newOAuth2Request($this->slim->request());
     $response = new OAuth2\Response();
     $isValid = $this->server->validateAuthorizeRequest($request, $response);
     if (!$isValid) {
         MessageBridge::mapResponse($response, $this->slim->response());
         return;
     }
     $authorized = $this->slim->request()->params('authorized');
     if (empty($authorized)) {
         $this->slim->render($this->template, ['client_id' => $request->query('client_id', false)]);
         return;
     }
     //@TODO implement user_id
     $this->server->handleAuthorizeRequest($request, $response, $authorized === 'yes');
     MessageBridge::mapResponse($response, $this->slim->response());
 }
Exemplo n.º 3
0
 public function __invoke()
 {
     $request = MessageBridge::newOAuth2Request($this->slim->request());
     MessageBridge::mapResponse($this->server->handleTokenRequest($request), $this->slim->response());
 }