Function used to check if the `auth` parameter is set on a Pushwoosh request and if no try to set it from the
Pushwoosh client `auth` parameter.

@param \Gomoob\Pushwoosh\Model\IRequest $request The Pushwoosh request to update.
973043
private function setAuthIfNotSet(IRequest $request)
    {
        // If the 'auth' parameter is not set in the request we try to get it from the Pushwoosh client
        if ($request->getAuth() === null) {
            // The 'auth' parameter is expected here
            if (!isset($this->auth)) {
                throw new PushwooshException('The \'auth\' parameter is not set !');

                // Use the 'auth' parameter defined in the Pushwoosh client
            } else {
                $request->setAuth($this->auth);
            }
        }
    }
1164381
public function authenticate($request) {
		if(!$this->configured)
			return;
		
		$this->checkValidity();
		
		if($this->via == self::HTTP_HEADER)
			$request->addHeader($this->description->http_header, $this->token);
	}
249152
public function do_request($request)
    {
        $http = [];

        $http['method'] = $request->method;

        $headers = [];
        foreach ($request->headers as $k => $v) {
            $headers[] = is_string($k) ? "$k: $v" : $v;
        }

        if (isset($request->options['proxy'])) {
            $parts = parse_url($request->options['proxy']);
            if ($parts['scheme'] !== 'http') {
                throw new NotSupportedException(['only support http type proxy: `:proxy`', 'proxy' => $request->options['proxy']]);
            }

            if (isset($parts['pass'])) {
                $headers[] = 'Proxy-Authorization: Basic ' . base64_encode($parts['user'] . ':' . $parts['pass']);
            }
            $http['proxy'] = 'tcp://' . $parts['host'] . ':' . (isset($parts['port']) ? $parts['port'] : '80');
        }

        $http['header'] = $headers;

        if (is_string($request->body)) {
            $http['content'] = $request->body;
        } elseif (is_array($request->body)) {
            if (isset($options['Content-Type']) && strpos($request->headers['Content-Type'], 'json') !== false) {
                $http['content'] = json_encode($request->body, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
            } else {
                $http['content'] = http_build_query($request->body);
            }
        }

        $http['timeout'] = $request->options['timeout'];
        $http['ignore_errors'] = true;

        $ssl = [];
        $ssl['verify_peer'] = $request->options['verify_peer'];
        if (isset($request->options['allow_self_signed'])) {
            $ssl['allow_self_signed'] = $request->options['allow_self_signed'];
        } else {
            $ssl['allow_self_signed'] = !$request->options['verify_peer'];
        }

        if (isset($request->options['cafile'])) {
            $ssl['cafile'] = $this->alias->resolve($request->options['cafile']);
        }

        $start_time = microtime(true);

        if (!$stream = @fopen($request->url, 'rb', false, stream_context_create(['http' => $http, 'ssl' => $ssl]))) {
            throw new ConnectionException(['`:url`: `:last_error_message`', 'url' => $request->url]);
        }
        $meta = stream_get_meta_data($stream);
        $body = stream_get_contents($stream);
        fclose($stream);

        $process_time = round(microtime(true) - $start_time, 3);

        $headers = $meta['wrapper_data'];

        for ($i = count($headers) - 1; $i >= 0; $i--) {
            $header = $headers[$i];
            /** @noinspection NotOptimalIfConditionsInspection */
            if (strpos($header, ':') === false && $headers !== '') {
                break;
            }
        }

        if ($i !== 0) {
            $headers = array_slice($headers, $i);
        }

        $content_type = null;
        foreach ($headers as $header) {
            if (strpos($header, 'Content-Type:') === 0) {
                $content_type = trim(substr($header, 13));
                break;
            }
        }

        $http_code = null;
        if ($headers && preg_match('#\d{3}#', $headers[0], $match)) {
            $http_code = (int)$match[0];
        }

        $response = new Response();
        $response->url = $request->url;
        $response->remote_ip = null;
        $response->http_code = $http_code;
        $response->headers = $headers;
        $response->process_time = 0;
        $response->content_type = $content_type;
        $response->body = $body;
        $response->process_time = $process_time;

        return $response;
    }
229320
public function auth($request)
    {
        if (Str::startsWith($request->channel_name, ['private-', 'presence-']) &&
            ! $request->user()) {
            throw new AccessDeniedHttpException;
        }

        $channelName = Str::startsWith($request->channel_name, 'private-')
                            ? Str::replaceFirst('private-', '', $request->channel_name)
                            : Str::replaceFirst('presence-', '', $request->channel_name);

        return parent::verifyUserCanAccessChannel(
            $request, $channelName
        );
    }
240352
public function setRequest(Request $request = null)
    {
        $this->request = $request;
        // try to set User-Agent from original request
        if ($request && $this->browser) {
            $this->browser->setDefaultHeaders([
                'User-Agent' => $request->server->get('HTTP_USER_AGENT', self::DEFAULT_USER_AGENT),
            ]);
        }
    }
102832
public function checkForToken(Request $request)
    {
        if (! $this->auth->parser()->setRequest($request)->hasToken()) {
            throw new UnauthorizedHttpException('jwTauth', 'Token not provided');
        }
    }
213521
public function authenticate(IRequest $request)
    {
        // resolve token type from request
        $tokenType = $this->tokenTypeResolver->resolve($request);

        $accessToken = $this->accessTokenStorage->get($tokenType->getAccessToken());

        if (!$accessToken) {
            throw new NotAuthenticatedException;
        }

        return new Session($accessToken);
    }
93107
public function setRequest(SimplifiedRequest $request)
    {
        if (!$this->key) {
            $this->setMapKey($request->host);
        }

        parent::setRequest($request);
    }
1284036
public function handleHttpRequest($request)
    {
        $this->parseRequestBase($request);

        if (isset($request->header['x-rpc']) && $request->header['x-rpc'] == 1) {
            $this->routeParams->isRpc          = true;
            $this->routeParams->params         = $request->post ?? $request->get ?? [];
            $this->routeParams->controllerName = 'Rpc';
            $this->routeParams->methodName     = 'Index';
            $this->controllerClassName         = '\PG\MSF\Controllers\Rpc';
            $this->routeParams->path           = '/Rpc/Index';
        } else {
            if ($this->routeParams->path) {
                $this->parsePath($this->routeParams->path);
            }
        }
    }
1123921
private function authenticate($request)
    {
        switch (strtolower($this->authN_type)) {

            case 'cas':
                // Use CAS authentication.
                $casAuth = new UsfAuthCAS($this->config['cas']);
                $casAuth->auth();

                //Authorization check
                $this->isAuthorized = $casAuth->isAuthorized($this->authZ_roles);

                //Add the username and entitlements to the request
                $request = $request->withHeader('AUTH_PRINCIPAL', $casAuth->getPrincipal());
                $request = $request->withHeader('AUTH_ENTITLEMENTS', $casAuth->getEntitlements());

                //Add all Attributes
                foreach ($casAuth->getAttributes() as $key => $value) {
                    $request = $request->withHeader('AUTH_ATTR_'.strtoupper($key), $value);
                }
                break;

            case 'token':
                // Use the USF Token Auth library.
                $tokenAuth = new UsfAuthToken(
                    $this->config['token']['app_id'],
                    $this->config['token']['token_url']
                );

                $tokenAuth->setRequestMethod($request->getMethod());
                $tokenAuth->setReferrer($request->getHeader('HTTP_REFERER'));

                //Validate request token
                $tokenAuth->validateRequest($request->getHeader('HTTP_X_AUTH_TOKEN'));

                //Authorization check
                $this->isAuthorized = $tokenAuth->isAuthorized($this->authZ_roles);

                //Add the username and entitlements to the request
                $request = $request->withHeader('AUTH_PRINCIPAL', $tokenAuth->getPrincipal());
                $request = $request->withHeader('AUTH_ENTITLEMENTS', $tokenAuth->getEntitlements());

                //Add all Attributes
                foreach ($tokenAuth->getAttributes() as $key => $value) {
                    $request = $request->withHeader('AUTH_ATTR_'.strtoupper($key), $value);
                }
                break;

            case 'hmac':
                // HMAC authentication: https://github.com/acquia/http-hmac-spec
                $hmacAuth = new UsfAuthHmac($this->config['hmac']['keyRegistry']);
                if (!empty($this->config['hmac']['timeout'])) {
                    $hmacAuth->setTimeout($this->config['hmac']['timeout']);
                }

                $hmacAuth->setRequestWrapper(new Psr7Request($request));

                try {
                    $hmacAuth->authenticate();
                    $this->isAuthorized = true;
                } catch (\Exception $exception) {
                    $this->isAuthorized = false;
                }

                //Add the username to the request
                $request = $request->withHeader('AUTH_PRINCIPAL', $hmacAuth->getPrincipal());
                break;

            case 'permitall':
                // No authentication - let everyone in.
                $this->isAuthorized = true;
                break;

            case 'denyall':
                // No authentication - keep everyone out.
                $this->isAuthorized = false;
                break;

            default:
                throw new \Exception("Unknown Authentication type: " . $this->authN_type, 500);
                break;
        }

        return $request;
    }
348813
protected function authenticate($request) : bool
  {
    $basic = base64_decode(substr($request->header('Authorization'), 6));

    $user = explode(':', $basic)[0];
    $pass = explode(':', $basic)[1];

    $response = Auth::attempt([
      $this->checks['user'] => $user,
      $this->checks[
        config('auth.provider.' . $this->provider . '.protects')
      ] => $pass
    ],
      $this->hidden,
      $this->provider
    );

    if ($response instanceof Model) {
      Auth::grant($response);
      return true;;
    }

    return false;
  }
1245700
public function supportRequestToken(Request $request)
    {
        $clientExist = $request->getUser() && $request->getPassword();
        $oauthParams = $request->get('grant_type') === 'client_credentials';

        return $oauthParams && $clientExist;
    }
167884
private function setRequest(Request $request = null)
    {
        $this->request = $request;
        $this->override = null;
    }
1097732
public function authenticate(Request $request)
    {
        $this->checkForToken($request);

        try {
            if (! $this->auth->parseToken()->authenticate()) {
                throw new UnauthorizedHttpException('jwTauth', 'User not found');
            }
        } catch (JwTException $e) {
            throw new UnauthorizedHttpException('jwTauth', $e->getMessage(), $e, $e->getCode());
        }
    }
339796
public function setRequest(Request $request)
    {
        $this->request = $request;

        $this->input = $request->request->all() + $request->query->all();
    }
269793
public static function updateRequest($request) {
        $routeModel = Dir::apiModel(static::$model);
        $heroe = $routeModel::find($request->id);

        foreach($heroe->getTuples() as $tuple)
            if(!empty($request->$tuple))
                $heroe->$tuple = $request->$tuple;

        $heroe->update();
        return $heroe;
    }
661097
protected function insertCredentials($request) {
		$request->setData('Username', $this->api_username);
		$request->setData('Password', $this->api_password);

		$signature = $this->signMerchantRequest($request);
		if($signature === FALSE) {
			return FALSE;
		}
		$request->setParam('Signature', $signature);

		return TRUE;
	}