Determine if the password token is valid.

@param  RequestInterface $request The PSR-7 HTTP request.
@return boolean
964327
public function init(RequestInterface $request)
    {
        // Undocumented Slim 3 feature: The route attributes are stored in routeInfo[2].
        $routeInfo = $request->getAttribute('routeInfo');

        if (isset($routeInfo[2]['token'])) {
            $this->lostPasswordToken = $routeInfo[2]['token'];
        } else {
            $this->lostPasswordToken = $request->getParam('token');
        }

        if ($this->lostPasswordToken && $this->validateToken($this->lostPasswordToken)) {
            return true;
        }

        header('HTTP/1.0 400 Bad Request');
        header('Location: '.$this->adminUrl('account/lost-password?notice=invalidtoken'));
        exit;
    }
105641
public function addAuthHeader(RequestInterface $request)
    {
        if (!empty($this->token['access_token'])) {
            return $request->withHeader(
                'Authorization',
                'Bearer ' . $this->token['access_token']
            );
        }

        return $request->withHeader(
            'Authorization',
            'Client-ID ' . $this->clientId
        );
    }
187723
protected function tokenMatches($request) : bool
  {
    if (!isset( $_SESSION['_saini']) || !$_SESSION['_saini']) return false;

    $csrfToken = $request->has('csrf_token') ? $request->input('csrf_token') : ($request->headers->has('X-CSRF-TOKEN') ? $request->header('X-CSRF-TOKEN') : null);
    $sessionToken =  $_SESSION['_saini'];

    if (!hash_equals($sessionToken, $csrfToken)) {
      return false;
    }

    return true;
  }
1009894
public function validateRequest(RequestInterface $request, ResponseInterface $response)
	{
		// check HTTP basic auth headers for client id/secret
		if (!is_null($request->headers('PHP_AUTH_USER')) && !is_null($request->headers('PHP_AUTH_PW')))
		{
			$clientData = array(
				'client_id'     => $request->headers('PHP_AUTH_USER'),
				'client_secret' => $request->headers('PHP_AUTH_PW')
			);
		}

		// if we allow credentials via request body look there
		if ($this->config['allow_credentials_in_request_body'])
		{
			// check for client id in request
			if (!is_null($request->request('client_id')))
			{
				$clientData = array(
					'client_id'     => $request->request('client_id'),
					'client_secret' => $request->request('client_secret')
				);
			}
		}

		// must have client id
		if (!isset($clientData['client_id']) || $clientData['client_id'] == '')
		{
			$message = $this->config['allow_credentials_in_request_body'] ? ' or body' : '';
			$response->setError(400, 'invalid_client', 'Client credentials were not found in the headers'.$message);
			return false;
		}

		// check to see if we have client secret
		if (!isset($clientData['client_secret']) || $clientData['client_secret'] == '')
		{
			// invalid if we dont have client secret and public clients are off
			if (!$this->config['allow_public_clients'])
			{
				$response->setError(400, 'invalid_client', 'client credentials are required');
				return false;
			}

			// check storage if client is public client
			if (!$this->storage->isPublicClient($clientData['client_id']))
			{
				$response->setError(400, 'invalid_client', 'This client is invalid or must authenticate using a client secret');
				return false;
			}
		}
		// if we do have a secret lets verify them
		elseif ($this->storage->checkClientCredentials($clientData['client_id'], $clientData['client_secret']) === false)
		{
			$response->setError(400, 'invalid_client', 'The client credentials are invalid');
			return false;
		}

		// store data locally
		$this->clientData = $clientData;
		return true;
	}
797970
private static function isValidOrigin(RequestInterface $request): bool
    {
        if (!self::compareHeaderUrl($request, 'Origin')) {
            return false;
        }

        if (!self::compareHeaderUrl($request, 'Referer')) {
            return false;
        }

        return true;
    }
792349
public function authenticate(RequestInterface $request)
    {
        $token = $this->token();

        if (!$token && !$this->findMatchingArea($request)) {
            return $this;
        }

        if (!$token) {
            throw new AuthenticationException('Unable to authenticate, token is missing');
        }

        foreach ($this->providers as $provider) {
            if (!$provider->supportsToken($token)) {
                continue;
            }

            if (!$provider->authenticate($token)) {
                $this->stash()
                     ->destroy();

                throw new AuthenticationException(sprintf('Token could not be authenticated in provider "%s", destroying token', get_class($provider)));
            }

            $this->user = $provider->get($token);

            return $this;
        }

        $this->stash()
             ->destroy();

        throw new AuthenticationException(sprintf('Missing provider supporting token "%s", destroying token', get_class($token)));
    }
1201949
public function filter($request)
    {
        // Check if user is authenticated via an auth session
        $this->session_authenticated = $this->isUserSessionAuthenticated();

        // Check if user is authenticated via an auth token
        $this->token_authenticated = $this->isUserTokenAuthenticated($request);

        // Decide if user is authenticated
        $this->user_authenticated = $this->isUserAuthenticated([$this->session_authenticated, $this->token_authenticated]);

        if ($this->user_authenticated === false)
        {
            // There is no way to know, for definite, which 'method' a user intended to authenticate, unless a token was
            // used, in which case it is safe to assume which method they were using.
            // In cases where a token wasn't given and the user has requested a JSON response, we assume they were trying
            // to use token authentication. Otherwise we assume they were trying to use session authentication.

            // Note: This approach maybe revised in the future.

            if (($this->token_authenticated !== false && $this->token_authenticated instanceof MissingTokenException === false) || Request::wantsJson())
            {
                $this->tokenAuthenticationFailure();
            }

            $this->sessionAuthenticationFailure();
            // BUG: For some reason issuing a redirect within a function other than this one doesn't do anything.
            return Redirect::guest('login');
        }
    }
701074
protected function tokensMatch( $request )
	{
		$sessionToken = $request->session()->token();
		$token = $request->input( '_token' ) ?: $request->header( 'X-CSRF-TOKEN' );
		if ( !$token && $header = $request->header( 'X-XSRF-TOKEN' ) )
		{
			$token = $this->encrypter->decrypt( $header );
		}
		if ( !is_string( $sessionToken ) || !is_string( $token ) )
		{
			return false;
		}

		return hash_equals( $sessionToken, $token );
	}
1241692
protected function authenticate($request) : bool
  {
    $bearer = substr($request->header('Authorization'), 6);
    $token  = explode(' ', $bearer)[1];

    try {
      $payLoad = $this->validateToken($token);
    }
    catch (TokenValidatorException $e) {
      $this->fails($e);
      cancel();
    }

    $userid   = $payLoad['iss'];
    $provider = $payLoad['pro'];

    $model = config('auth.provider.' . $provider . '.model');

    Auth::grant($model::where('id', $userid)->firstOrFail());

    return true;
  }
480032
private function isValid(ServerRequestInterface $request)
    {
        $data = $request->getParsedBody();

        return isset($data[$this->inputName]) && $data[$this->inputName] === '';
    }
1254949
public function isAcceptable(RequestInterface $request)
    {
        $accept = $request->getHeaderLine('Accept');
        if ($accept && preg_match('#^application/([^+\s]+\+)?json#', $accept)) {
            return true;
        }

        return false;
    }
1231151
public function validateAuthorizationRequest(ServerRequestInterface $request)
    {
        foreach ($this->enabledGrantTypes as $grantType) {
            if ($grantType->canRespondToAuthorizationRequest($request)) {
                return $grantType->validateAuthorizationRequest($request);
            }
        }

        throw OAuthServerException::unsupportedGrantType();
    }
931233
protected function isAuthenticated($request)
    {
        global $logger;
        global $app;

        $session = $app->getSessionManager()->getActiveSession();
        $subject = $app->getSubject();
        return ($request->getParam('rand_token') == $session->getAttribute('nonce')) && $subject->isAuthenticated();

    }
1102015
private function tokenShouldNotBeChecked(Request $request) : bool
    {
        return in_array($request->getMethod(), [RequestMethods::GET, RequestMethods::HEAD, RequestMethods::OPTIONS]);
    }
67620
public function getTokenFromRequest( RequestInterface $request ) {
		if ( $request->get( $this->key ) ) {
			return $request->get( $this->key );
		}

		if ( $request->post( $this->key ) ) {
			return $request->post( $this->key );
		}

		if ( $request->headers( $this->header ) ) {
			return $request->headers( $this->header );
		}

		return '';
	}
500635
private function authenticateRequest(RequestInterface $request, AccessToken $token)
    {
        foreach ($this->provider->getHeaders($token->getToken()) as $name => $value) {
            $request = $request->withHeader($name, $value);
        }

        return $request;
    }
79591
public function validateRequest(RequestInterface $request, ResponseInterface $response)
	{
		// check for session id
		if (!$sessionId = $this->storage->getSessionIdFromCookie())
		{
			$response->setError(401, 'session_authentication_invalid', 'Unable to find a valid session id.');
			return false;
		}

		// get user for session id
		if (!$userId = $this->storage->getUserIdFromSessionId($sessionId))
		{
			$response->setError(401, 'session_authentication_invalid', 'Unable to authenticate via active session.');
			return false;
		}

		// store our session & user id
		$this->userInfo = array(
			'user_id'    => $userId,
			'session_id' => $sessionId
		);
		return true;
	}