当前位置: 首页>>代码示例>>PHP>>正文


PHP Server::getResponse方法代码示例

本文整理汇总了PHP中OAuth2\Server::getResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::getResponse方法的具体用法?PHP Server::getResponse怎么用?PHP Server::getResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OAuth2\Server的用法示例。


在下文中一共展示了Server::getResponse方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($bypassPaths = array(), $bypassAuth = false)
 {
     $this->useOAuth2 = API_USE_OAUTH;
     if ($this->useOAuth2) {
         $this->initOAth2();
         // Don't check for authorization when requesting a token or docs
         $temp = explode('/', trim($_SERVER['REQUEST_URI'], '/'));
         $lastPath = str_replace($_SERVER['QUERY_STRING'], '', $temp[count($temp) - 1]);
         $lastPath = str_replace('?', '', $lastPath);
         if ($bypassAuth == false && $lastPath != 'authorize' && $lastPath != 'docs') {
             $continue = true;
             foreach ($bypassPaths as $path) {
                 if ($lastPath == $path) {
                     $continue = false;
                 }
             }
             if ($continue) {
                 // Check for a valid token
                 if (!$this->oauthServer->verifyResourceRequest(\OAuth2\Request::createFromGlobals())) {
                     // Not authorized!
                     $this->oauthServer->getResponse()->send();
                     die;
                 }
             }
         }
     }
 }
开发者ID:jimgitsit,项目名称:php-gozer,代码行数:27,代码来源:CoreAPI.php

示例2: __invoke

 /**
  * 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());
 }
开发者ID:chadicus,项目名称:slim-oauth2-middleware,代码行数:20,代码来源:Authorization.php

示例3: authorize

 /**
  * Stage 1: Client sends the user to this page
  *
  * User responds by accepting or denying
  *
  * @view oauth2/server/authorize.twig
  * @format HtmlFormat
  */
 public function authorize()
 {
     static::$server->getResponse(static::$request);
     // validate the authorize request.  if it is invalid,
     // redirect back to the client with the errors in tow
     if (!static::$server->validateAuthorizeRequest(static::$request)) {
         static::$server->getResponse()->send();
         exit;
     }
     return array('queryString' => $_SERVER['QUERY_STRING']);
 }
开发者ID:raven7,项目名称:Restler,代码行数:19,代码来源:Server.php

示例4: call

 /**
  * 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();
     }
 }
开发者ID:salt-lick,项目名称:slim-oauth2-middleware,代码行数:22,代码来源:Authorization.php

示例5: __invoke

 /**
  * {@inheritDoc}
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
 {
     try {
         $oauth2request = Util::convertRequestFromPsr7($request);
         if (!$this->server->verifyResourceRequest($oauth2request)) {
             return Util::convertResponseToPsr7($this->server->getResponse(), $response);
         }
         $request = $request->withAttribute('access_token', $this->server->getAccessTokenData($oauth2request));
     } catch (\Exception $ex) {
         return new JsonResponse(['error' => $ex->getMessage(), 'error_description' => $ex->getMessage()], 500);
     }
     return $next($request, $response);
 }
开发者ID:tonis-io,项目名称:oauth2,代码行数:16,代码来源:TokenMiddleware.php

示例6: checkAuth

 /**
  * @param Route $route
  * @throws \Slim\Exception\Stop
  */
 private function checkAuth(Route $route)
 {
     $request = OAuth2\Request::createFromGlobals();
     $scopeRequired = [];
     if ($route->isSecure()) {
         $scopeRequired = 'admin';
     }
     if (!$this->oauth->verifyResourceRequest($request, NULL, $scopeRequired)) {
         $response = $this->oauth->getResponse();
         $this->app->response()->status($response->getStatusCode());
         $response->send();
         $this->app->stop();
     }
 }
开发者ID:alexdevid,项目名称:slim-rest,代码行数:18,代码来源:Kernel.php

示例7: resourceAction

 /**
  * Test resource (/oauth/resource)
  */
 public function resourceAction()
 {
     // Handle a request for an OAuth2.0 Access Token and send the response to the client
     if (!$this->server->verifyResourceRequest($this->getOAuth2Request())) {
         $response = $this->server->getResponse();
         $parameters = $response->getParameters();
         $errorUri = isset($parameters['error_uri']) ? $parameters['error_uri'] : null;
         return new ApiProblemResponse(new ApiProblem($response->getStatusCode(), $parameters['error_description'], $errorUri, $parameters['error']));
     }
     $httpResponse = $this->getResponse();
     $httpResponse->setStatusCode(200);
     $httpResponse->getHeaders()->addHeaders(array('Content-type' => 'application/json'));
     $httpResponse->setContent(json_encode(array('success' => true, 'message' => 'You accessed my APIs!')));
     return $httpResponse;
 }
开发者ID:alapini,项目名称:apigility-3hr-tutorial,代码行数:18,代码来源:AuthController.php

示例8: onDispatch

 /**
  * Method executed when the dispatch event is triggered
  *
  * @param MvcEvent $e 
  * @return void
  */
 public static function onDispatch(MvcEvent $e)
 {
     if ($e->getRequest() instanceof \Zend\Console\Request) {
         return;
     }
     if ($e->getRouteMatch()->getMatchedRouteName() == 'login' || $e->getRouteMatch()->getMatchedRouteName() == 'users') {
         return;
     }
     $sm = $e->getApplication()->getServiceManager();
     $usersTable = $sm->get('Users\\Model\\UsersTable');
     $storage = new Pdo($usersTable->adapter->getDriver()->getConnection()->getConnectionParameters());
     $server = new Server($storage);
     if (!$server->verifyResourceRequest(Request::createFromGlobals())) {
         $model = new JsonModel(array('errorCode' => $server->getResponse()->getStatusCode(), 'errorMsg' => $server->getResponse()->getStatusText()));
         $response = $e->getResponse();
         $response->setContent($model->serialize());
         $response->getHeaders()->addHeaderLine('Content-Type', 'application/json');
         $response->setStatusCode($server->getResponse()->getStatusCode());
         return $response;
     }
 }
开发者ID:CPDeutschland,项目名称:zf2-api-client,代码行数:27,代码来源:OAuthListener.php

示例9: resource

 public function resource($path)
 {
     // Handle a request for an OAuth2.0 Access Token and send the response to the client
     if (!$this->server->verifyResourceRequest(Request::createFromGlobals())) {
         $this->server->getResponse()->send();
         die;
     }
     $token = $this->server->getAccessTokenData(Request::createFromGlobals());
     $return = array();
     if (is_callable($this->resourceHandler)) {
         $return = call_user_func($this->resourceHandler, $path, $token['user_id']);
     }
     echo json_encode($return);
 }
开发者ID:paliari,项目名称:oauth2-server-facade,代码行数:14,代码来源:Oauth2Facade.php

示例10: authenticate

 /**
  * Attempt to authenticate the current request.
  *
  * @param Request $request
  * @param Response $response
  * @param MvcAuthEvent $mvcAuthEvent
  * @return false|Identity\IdentityInterface False on failure, IdentityInterface
  *     otherwise
  */
 public function authenticate(Request $request, Response $response, MvcAuthEvent $mvcAuthEvent)
 {
     $oauth2request = new OAuth2Request($request->getQuery()->toArray(), $request->getPost()->toArray(), [], $request->getCookie() ? $request->getCookie()->getArrayCopy() : [], $request->getFiles() ? $request->getFiles()->toArray() : [], method_exists($request, 'getServer') ? $request->getServer()->toArray() : $_SERVER, $request->getContent(), $request->getHeaders()->toArray());
     // Failure to validate
     if (!$this->oauth2Server->verifyResourceRequest($oauth2request)) {
         $oauth2Response = $this->oauth2Server->getResponse();
         $status = $oauth2Response->getStatusCode();
         // 401 or 403 mean invalid credentials or unauthorized scopes; report those.
         if (in_array($status, [401, 403], true) && null !== $oauth2Response->getParameter('error')) {
             return $this->mergeOAuth2Response($status, $response, $oauth2Response);
         }
         // Merge in any headers; typically sets a WWW-Authenticate header.
         $this->mergeOAuth2ResponseHeaders($response, $oauth2Response->getHttpHeaders());
         // Otherwise, no credentials were present at all, so we just return a guest identity.
         return new Identity\GuestIdentity();
     }
     $token = $this->oauth2Server->getAccessTokenData($oauth2request);
     $identity = new Identity\AuthenticatedIdentity($token);
     $identity->setName($token['user_id']);
     return $identity;
 }
开发者ID:nuxwin,项目名称:zf-mvc-auth,代码行数:30,代码来源:OAuth2Adapter.php

示例11: verifyResourceRequest

 public function verifyResourceRequest(HttpRequest $httpRequest)
 {
     $oauthRequest = $this->buildRequest($httpRequest);
     $this->server->verifyResourceRequest($oauthRequest, null);
     return $this->buildResponse($this->determineFormat($httpRequest), new HttpResponse(), $this->server->getResponse());
 }
开发者ID:zource,项目名称:zource,代码行数:6,代码来源:OAuth.php


注:本文中的OAuth2\Server::getResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。