Пример #1
0
 /**
  * @param $inputs
  * @return string
  */
 private function getRequestMode($inputs)
 {
     $grantType = ProxyAux::getQueryValue($inputs, ProxyAux::GRANT_TYPE);
     $skip = ProxyAux::getQueryValue($inputs, $this->skipParam);
     $revoke = ProxyAux::getQueryValue($inputs, $this->revokeParam);
     $mode = ProxyAux::MODE_TOKEN;
     if (isset($grantType)) {
         if ($grantType === ProxyAux::PASSWORD_GRANT || $grantType === ProxyAux::CLIENT_CREDENTIALS_GRANT) {
             $mode = ProxyAux::MODE_LOGIN;
         }
     } else {
         if (isset($skip) && strtolower($skip) === 'true') {
             $mode = ProxyAux::MODE_SKIP;
         } else {
             if (isset($revoke) && strtolower($revoke) === 'true') {
                 $mode = ProxyAux::MODE_REVOKE;
             }
         }
     }
     return $mode;
 }
Пример #2
0
 /**
  * @param $inputs
  * @return string
  */
 private function getRequestMode($inputs)
 {
     $grantType = ProxyAux::getQueryValue($inputs, ProxyAux::GRANT_TYPE);
     $skip = ProxyAux::getQueryValue($inputs, $this->skipParam);
     $mode = ProxyAux::MODE_TOKEN;
     if (isset($grantType)) {
         if ($grantType === ProxyAux::PASSWORD_GRANT) {
             $mode = ProxyAux::MODE_LOGIN;
         } else {
             if ($grantType === ProxyAux::GUEST_GRANT) {
                 // add new grant type
                 $mode = ProxyAux::MODE_LOGIN;
             }
         }
     } else {
         if (isset($skip) && strtolower($skip) === 'true') {
             $mode = ProxyAux::MODE_SKIP;
         }
     }
     return $mode;
 }
Пример #3
0
 /**
  * @param $method
  * @param $uriVal
  * @param $inputs
  * @return \GuzzleHttp\Message\FutureResponse|\GuzzleHttp\Message\ResponseInterface|\GuzzleHttp\Ring\Future\FutureInterface|mixed|null
  */
 private function sendGuzzleRequest($method, $uriVal, $inputs)
 {
     $options = array();
     $client = new Client();
     if ($this->callMode === ProxyAux::MODE_TOKEN && $this->useHeader === true) {
         $accessToken = ProxyAux::getQueryValue($inputs, ProxyAux::ACCESS_TOKEN);
         $inputs = ProxyAux::removeQueryValue($inputs, ProxyAux::ACCESS_TOKEN);
         $options = array_add($options, 'headers', [ProxyAux::HEADER_AUTH => 'Bearer ' . $accessToken]);
     }
     if ($method === 'GET') {
         $options = array_add($options, 'query', $inputs);
     } else {
         $options = array_add($options, 'body', $inputs);
     }
     $request = $client->createRequest($method, $uriVal, $options);
     try {
         $response = $client->send($request);
     } catch (ClientException $ex) {
         $response = $ex->getResponse();
     } catch (ServerException $ex) {
         $response = $ex->getResponse();
     }
     return $response;
 }