/** * Verify request contains valid access token. * * @param array $scopes Scopes required for authorization. $scopes can be given as an array of arrays. OR logic will * use with each grouping. Example: Given ['superUser', ['basicUser', 'aPermission']], the * request will be verified if the request token has 'superUser' scope OR 'basicUser' and * 'aPermission' as its scope * * @return void */ public function call(array $scopes = [null]) { if (!$this->verify($scopes)) { MessageBridge::mapResponse($this->server->getResponse(), $this->app->response()); $this->app->stop(); } //@codeCoverageIgnore since stop() throws $this->app->token = $this->server->getResourceController()->getToken(); if ($this->next !== null) { $this->next->call(); } }
/** * 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()); }
public function __invoke() { $request = MessageBridge::newOAuth2Request($this->slim->request()); MessageBridge::mapResponse($this->server->handleTokenRequest($request), $this->slim->response()); }