Get request to be authenticated

@return RequestInterface
484553
public function getRequest()
    {
        if (null === $this->request) {
            $this->setRequest($this->getController()->getRequest());
        }

        return $this->request;
    }
213652
public function validateRequest()
    {
        $request = $this->framework->getRequest();
        
        // Parse the authorization information
        $authorization = $this->parseAuthorizationString($request->getHeader('Authorization'));
        $publicKey = $authorization['publicKey'];
        $hmac = $authorization['hmac'];
        
        // Verify the public key
        if (!$this->tokenManager->hasTokenForPublicKey($publicKey)) {
            return false;
        }
        
        // Load the token
        $token = $this->tokenManager->getTokenForPublicKey($publicKey);
        
        // Get the needed data
        $route = $request->getRoute();
        $data = $request->getParams();
        
        $result = $this->restHelper->validateRequest($token->getApiKey(), $hmac, $route, $data);
        
        if ($result) {
            return $token;
        }
        
        return false;
    }
116174
public function getAuthenticatedUser()
    {
        $user = $this->getStorage()
                     ->getAuthenticatedUser($this->request, $this->response);

        if ($user) {
            // check if the user needs 2FA verification
            $twoFactor = $this->getTwoFactorStrategy();
            if ($twoFactor && !$user->isTwoFactorVerified() && $twoFactor->needsVerification($user)) {
                $user->markSignedOut();
            }

            $this->setCurrentUser($user);
        } else {
            // if no current user then sign in a guest
            $user = $this->signInUser($this->getGuestUser());
        }

        return $user;
    }
615332
public function getRequest(): RequestInterface
    {
        if (is_null($this->request)) {
            if (method_exists($this, 'resolve')) {
                $this->setRequest($this->resolve(Request::class)->load());
            } else {
                $request = new Request();
                $this->setRequest($request->load());
            }
        }

        return $this->request;
    }
84926
public function auth()
    {
        $user     = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : null;
        $password = isset($_SERVER['PHP_AUTH_PW']) ? $_SERVER['PHP_AUTH_PW'] : null;

        if (is_null($user) || !(bool) call_user_func($this->verify, $user, $password)) {
            header(sprintf('WWW-Authenticate: Basic realm="%s"', $this->realm));
            header('HTTP/1.0 401 Unauthorized');

            if ($this->deny) {
                call_user_func($this->deny, $user);
            }

            exit;
        }

        $this->user     = $user;
        $this->password = $password;

        return $this;
    }
1082245
public function authenticate()
	{
		if ($data['code'] = $this->input->get('code', false, 'raw'))
		{
			$data['grant_type'] = 'authorization_code';
			$data['redirect_uri'] = $this->getOption('redirecturi');
			$data['client_id'] = $this->getOption('clientid');
			$data['client_secret'] = $this->getOption('clientsecret');
			$response = $this->http->post($this->getOption('tokenurl'), $data);

			if ($response->code >= 200 && $response->code < 400)
			{
				if ($response->headers['Content-Type'] == 'application/json')
				{
					$token = array_merge(json_decode($response->body, true), array('created' => time()));
				}
				else
				{
					parse_str($response->body, $token);
					$token = array_merge($token, array('created' => time()));
				}

				$this->setToken($token);

				return $token;
			}
			else
			{
				throw new \RuntimeException('Error code ' . $response->code . ' received requesting access token: ' . $response->body . '.');
			}
		}

		if ($this->getOption('sendheaders'))
		{
			$this->application->redirect($this->createUrl());
		}

		return false;
	}
163049
public function authenticate(Request $request)
    {
        if ($this->session->hasValue(User::SESSION_KEY)) {
            return $this->session->value(User::SESSION_KEY);
        }

        $user = $this->authenticationProvider->authenticate($request);
        if (null === $user) {
            return null;
        }

        $this->session->putValue(User::SESSION_KEY, $user);
        return $user;
    }
1042182
public function authenticate()
	{
		try {
			$proxy = $this->getProxy();

			if (!empty($_GET['oauth_token'])) {
				$token = $proxy->retrieveAccessToken();

				// This was a callback request, get the token now
				$proxy->requestAccessToken($_GET['oauth_token'], $_GET['oauth_verifier'], $token->getRequestTokenSecret());

				$this->authenticated = true;
			} else if ($proxy->hasValidAccessToken()) {
				$this->authenticated = true;
			} else {
				// extra request needed for oauth1 to request a request token :-)
				$token = $proxy->requestRequestToken();
				/** @var $url Uri */
				$url = $proxy->getAuthorizationUri(['oauth_token' => $token->getRequestToken()]);
				Yii::$app->getResponse()->redirect($url->getAbsoluteUri())->send();
			}
		} catch (OAuthException $e) {
			throw new ErrorException($e->getMessage(), $e->getCode(), 1, $e->getFile(), $e->getLine(), $e);
		}

		return $this->getIsAuthenticated();
	}
983560
public function authenticate(Request $request)
    {
        $form = $this->app->form(new PhraseaAuthenticationForm($this->app));
        $redirector = function (array $params = []) {
            return $this->app->redirectPath('homepage', $params);
        };

        try {
            return $this->doAuthentication($request, $form, $redirector);
        } catch (AuthenticationException $e) {
            return $e->getResponse();
        }
    }
803343
public function authenticate()
    {
        $request = new Request($this->handler);
        $this->token = $request->execute(
            RequestMethods::HTTP_POST,
            $this->makeUrl(RequestMethods::DOMUSERP_API_PEDIDOVENDA . '/auth'),
            [
                'json' => [
                    'login'    => $this->username,
                    'password' => $this->password
                ]
            ]
        )->token;

        return $this;
    }
296352
public function getAuthenticationClient()
    {
        if (null === $this->authenticationClient) {
            $this->authenticationClient = new Auth\OAuth2(
                $this->getHttpClient(),
                $this->getOption('client_id'),
                $this->getOption('client_secret')
            );
        }

        return $this->authenticationClient;
    }
146626
protected function authenticate()
    {
        $authClass = $this->config()->authenticator;
        $member = $authClass::authenticate();
        Security::setCurrentUser($member);
        return $member;
    }
983451
public function authenticated()
    {
        if (!$this->checkAuth()) {
            return response()->json(null, 401);
        }

        return response()->json(arrayView('phpsoft.users::user/read', [
            'user' => Auth::user()
        ]), 200);
    }
423874
public function authenticate() {
		$this->authenticated = $this->auth->authenticate();
		$error = $this->auth->getError();
		if (isset($error)) {
			throw new EAuthException($error);
		}

		// In case of successful authentication save access token and
		// customer to session.
		if ($this->authenticated) {
			$this->saveCredentials();
		}

		return $this->getIsAuthenticated();
	}
696524
public static function authenticate()
    {
        //if there is no username or password, fail
        if (!isset($_SERVER['PHP_AUTH_USER']) || !isset($_SERVER['PHP_AUTH_PW'])) {
            return null;
        }

        // With a valid user and password, check the password is correct
        $data = [
            'Email' => $_SERVER['PHP_AUTH_USER'],
            'Password' => $_SERVER['PHP_AUTH_PW'],
        ];
        $request = Controller::curr()->getRequest();
        $authenticators = Security::singleton()->getApplicableAuthenticators(Authenticator::LOGIN);
        $member = null;
        foreach ($authenticators as $authenticator) {
            $member = $authenticator->authenticate($data, $request);
            if ($member) {
                break;
            }
        }
        return $member;
    }
1278609
public function getRequestSignature()
    {
        if (empty($this->requestSignature)) {

            $string = $this->getApiId()
                . $this->getTimeStamp()
                . $this->getNonce()
                . $this->getDataString();

            $this->requestSignature = hash_hmac('sha1', $string, $this->getService()->getApiSecret());
        }

        return $this->requestSignature;
    }
606611
public function authenticate()
    {
        // go to google.com to get some cookies
        $request = $this->guzzleClient->createRequest('GET', 'http://www.google.com/ncr', ['cookies' => $this->cookieJar]);
        $response = $this->guzzleClient->send($request);

        // get google auth page html and fetch GALX
        $request = $this->guzzleClient->createRequest('GET', self::AUTH_URL, ['cookies' => $this->cookieJar]);
        $response = $this->guzzleClient->send($request);

        $content = $response->getBody()->getContents();

        $document = new \DOMDocument();
        @$document->loadHTML($content);

        $inputElements = $document->getElementsByTagName("input");

        $params = [];

        foreach ($inputElements as $input) {
            $params[$input->getAttribute("name")] = $input->getAttribute("value");
        }

        $params['Email'] = $this->email;
        $params['Passwd'] = $this->password;

        $params['pstMsg'] = '1';
        $params['continue'] = 'http://www.google.com/trends';

        // authenticate
        $request = $this->guzzleClient->createRequest('POST', self::AUTH_URL, ['cookies' => $this->cookieJar]);
        $query = $request->getQuery();


        foreach ($params as $key => $param) {
            $query->set($key, $param);
        }

        $response = $this->guzzleClient->send($request);

        // verify sign in if needed
        if (strpos($response->getEffectiveUrl(), 'LoginVerification') !== false) {
            $content = $response->getBody()->getContents();

            $document = new \DOMDocument();
            @$document->loadHTML($content);

            $inputElements = $document->getElementsByTagName("input");

            $params = [];

            foreach ($inputElements as $input) {
                $params[$input->getAttribute("name")] = $input->getAttribute("value");
            }

            $params['challengetype'] = 'RecoveryEmailChallenge';
            $params['emailAnswer'] = $this->recoveryEmail;

            $url = substr($response->getEffectiveUrl(), 0, strpos($response->getEffectiveUrl(), '?'));

            $request = $this->guzzleClient->createRequest('POST', $url, ['cookies' => $this->cookieJar]);
            $query = $request->getQuery();


            foreach ($params as $key => $param) {
                $query->set($key, $param);
            }

            $response = $this->guzzleClient->send($request);
        }

        // update cookies
        $response = $this->guzzleClient->get('https://www.google.com/accounts/CheckCookie?chtml=LoginDoneHtml',
            ['cookies' => $this->cookieJar],
            ['headers' =>
                ['Referrer' => 'https://www.google.com/accounts/ServiceLoginBoxAuth'],
            ]
        );

        // set language for trends
        $I4SUserLocale = new setCookie([
            'Name'     => 'I4SUserLocale',
            'Value'    => $this->language,
            'Domain'   => 'www.google.com',
            'Path'     => '/trends',
            'Secure'   => true,
            'HttpOnly' => true
        ]);

        $this->cookieJar->setCookie($I4SUserLocale);

        return $this;
    }