/** * Execute this middleware. * * @param ServerRequestInterface $request The PSR7 request. * @param ResponseInterface $response The PSR7 response. * @param callable $next The Next middleware. * * @return ResponseInterface */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next) { $oauth2Request = RequestBridge::toOAuth2($request); foreach ($this->scopes as $scope) { if ($this->server->verifyResourceRequest($oauth2Request, null, $scope)) { $this->container['token'] = $this->server->getResourceController()->getToken(); return $next($request, $response); } } return ResponseBridge::fromOAuth2($this->server->getResponse()); }
/** * Invoke this route callback. * * @param ServerRequestInterface $request Represents the current HTTP request. * @param ResponseInterface $response Represents the current HTTP response. * @param array $arguments Values for the current route’s named placeholders. * * @return ResponseInterface */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response, array $arguments = []) { $oauth2Request = Http\RequestBridge::toOAuth2($request); $oauth2Response = new OAuth2\Response(); if (!$this->server->validateAuthorizeRequest($oauth2Request, $oauth2Response)) { return Http\ResponseBridge::fromOAuth2($oauth2Response); } $authorized = $oauth2Request->request('authorized'); if (empty($authorized)) { $response = Http\ResponseBridge::fromOAuth2($oauth2Response); $this->view->render($response, $this->template, ['client_id' => $oauth2Request->query('client_id')]); return $response->withHeader('Content-Type', 'text/html'); } $this->server->handleAuthorizeRequest($oauth2Request, $oauth2Response, $authorized === 'yes'); return Http\ResponseBridge::fromOAuth2($oauth2Response); }
/** * Invoke this route callback. * * @param ServerRequestInterface $request Represents the current HTTP request. * @param ResponseInterface $response Represents the current HTTP response. * @param array $arguments Values for the current route’s named placeholders. * * @return RequestInterface */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response, array $arguments = []) { return ResponseBridge::fromOAuth2($this->server->handleTokenRequest(RequestBridge::toOAuth2($request))); }