验证csrf_token信息是否正确
@return bool
@throws TokenMismatchException
350353
public function verify()
    {
        if(strtoupper($this->vitex->env->method()) == 'POST' ||
            strtoupper($this->vitex->env->method()) == 'PUT'
        ) {
            $token = $this->vitex->req->body->_token;
            if(!$token){
                $token = $this->vitex->env->get('HTTP_X_CSRF_TOKEN');
            }
            $cookieToken = $this->vitex->req->cookies->csrf_token;
            $pathinfo = $this->vitex->env->getPathinfo();
            $except = $this->vitex->getConfig('csrf.except');
            if($token != $cookieToken){
                /*
                 * 一个符合排除的链接就排除
                 */
                foreach($except as $pattern){
                    if($this->vitex->route->router->checkUrlMatch($pattern,$pathinfo)){
                        return true;
                    }
                }

                //验证失败出错
                $callback = $this->vitex->getConfig('csrf.onmismatch');
                if($callback){
                    call_user_func_array($callback,[$token,$cookieToken]);
                    exit;
                } else {
                    throw new TokenMismatchException("CSRF TOKEN验证失败",Exception::CODE_PARAM_VALUE_ERROR);
                }
            }
        }
        return true;
    }
1275812
protected function validCsrf($token, $request)
    {
        return isset($token['csrf']) && hash_equals(
            $token['csrf'], (string) $request->header('X-CSRF-TOKEN')
        );
    }
296123
public function checkToken($request_token)
    {
        $token_manager = $this->container->get('security.csrf.token_manager');
        $token = new CsrfToken('file_manager', $request_token);
        $valid = $token_manager->isTokenValid($token);

        if (!$valid) {
            throw new InvalidCsrfTokenException();
        }
    }
1094721
public function checkValid()
	{
		if (!$this->cookie || !$this->_token) return false;
		$send_snoopy = new Snoopy; 
		$post = array('ajax'=>1,'token'=>$this->_token);
		$submit = "https://mp.weixin.qq.com/cgi-bin/getregions?id=1017&t=ajax-getregions&lang=zh_CN";
		$send_snoopy->rawheaders['Cookie']= $this->cookie;
		$send_snoopy->submit($submit,$post);
		$result = $send_snoopy->results;
		if(json_decode($result,1)){
			return true;
		}else{
			return false;
		}
	}
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;
  }
614856
public function generateCsrfToken() {
		$token = hash("sha512", mt_rand(0, mt_getrandmax()));
		$_SESSION[$this->csrfTokenSessionKey] = $token;
		return $token;
	}
1204448
private function hasStoredCsrfToken()
    {
        if ($this->csrfTokenManager === null) {
            return true;
        }

        return $this->csrfTokenManager->hasToken($this->csrfTokenIntention);
    }
747066
protected function validateAction()
    {
        $token = (isset($this->validationToken)) ? $this->validationToken : get_class($this);
        if (!$this->app->make('token')->validate($token)) {
            $this->error->add($this->app->make('token')->getErrorMessage());

            return false;
        }
        if (!$this->canAccess()) {
            return false;
        }

        return true;
    }
1344194
protected function checkCsrfToken(Request $request)
    {
        if (!$request->headers->has(self::CSRF_TOKEN_HEADER)) {
            return false;
        }

        return $this->csrfTokenManager->isTokenValid(
            new CsrfToken(
                $this->csrfTokenIntention,
                $request->headers->get(self::CSRF_TOKEN_HEADER)
            )
        );
    }
699947
public function checkTokenAnswersAction()
    {
        $token       = $this->getToken();
        $where       = $this->db->quoteInto('gto_id_token = ?', $token->getTokenId());
        $batch = $this->loader->getTracker()->recalculateTokens(
                'answersCheckToken__' . $token->getTokenId(),
                $this->currentUser->getUserId(),
                $where
                );
        $batch->autoStart = true;

        $title = sprintf(
                $this->_("Checking the token %s for answers."),
                $token->getTokenId()
                );
        $this->_helper->BatchRunner($batch, $title, $this->accesslog);

        $this->addSnippet('Survey\\CheckAnswersInformation',
                'itemDescription', $this->_('This task checks one token for answers.')
                );
    }
723290
public function validateToken() {
        $userData = $this->_store->userData;
        $currToken = $this->_store->token;
        $checkToken = $this->createToken(serialize($userData));
        return $checkToken === $currToken;
    }
1039014
public function getCsrfToken()
    {
        if (!$this->csrfToken) {
            $segment = $this->getSegment(self::CSRF_TOKEN);
            $this->csrfToken = new CsrfToken($segment);
        }

        return $this->csrfToken;
    }
75776
private function renderCsrfToken() {
		
		$tokenManager = new CsrfTokenManager();
		$token = $tokenManager->refreshToken('_' . $this->action . '_');

		$e = new InputElement(self::CSRF_TOKEN_NAME, $token->getValue());
		$e->setAttribute('type', 'hidden');
		
		return $e->render();
	}
997771
public function check() {
        if (! self::$active) {
            return;
        }
        
        // Check sessions are enabled.
        if (session_id() === '') {
            throw new \Exception('Sessions are required to use the CSRF Guard middleware.');
        }
        
        if (isset($_SESSION["csrf_time"])) {
            $expired = (time() - $_SESSION["csrf_time"]) > 3600;
        } else {
            $expired = true;
        }
        
        if (isset($_GET["expire_token"])) {
            $_SESSION["csrf_time"] = time() - 10000;
        }
        
        if (! isset($_SESSION[$this->key]) || $expired) {
            $_SESSION[$this->key] = sha1(serialize($_SERVER) . rand(0, 0xffffffff));
            $_SESSION["csrf_time"] = time();
        }
        
        $token = $_SESSION[$this->key];
        // Validate the CSRF token.
        if (in_array($this->app->request()->getMethod(), array('POST', 'PUT', 'DELETE'))) {
            $userToken = $this->app->request()->post($this->key);
       
            if ($token !== $userToken) {
                $this->app->halt(400, 'Invalid or missing or expired CSRF token.');
            }
        }
        // Assign CSRF token key and value to view.
        self::$token = $token;
    }
105583
public function getCsrfToken() {
		if (!isset($_SESSION[$this->csrfTokenSessionKey])) {
			$this->generateCsrfToken();
		}
		return $_SESSION[$this->csrfTokenSessionKey];
	}
164571
public function getCsrfProtectionToken()
    {
        $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class);
        $csrfProtectionTokens = $sessionDataContainer->getCsrfProtectionTokens();
        if ($this->csrfProtectionStrategy === self::CSRF_ONE_PER_SESSION && count($csrfProtectionTokens) === 1) {
            reset($csrfProtectionTokens);
            return key($csrfProtectionTokens);
        }

        if ($this->csrfProtectionStrategy === self::CSRF_ONE_PER_REQUEST) {
            if (empty($this->requestCsrfToken)) {
                $this->requestCsrfToken = Algorithms::generateRandomToken(16);
                $csrfProtectionTokens[$this->requestCsrfToken] = true;
                $sessionDataContainer->setCsrfProtectionTokens($csrfProtectionTokens);
            }

            return $this->requestCsrfToken;
        }

        $newToken = Algorithms::generateRandomToken(16);
        $csrfProtectionTokens[$newToken] = true;
        $sessionDataContainer->setCsrfProtectionTokens($csrfProtectionTokens);

        return $newToken;
    }
1216569
public static function csrfCheck() {
        if ($_SERVER['REQUEST_METHOD'] == 'POST' || $_SERVER['REQUEST_METHOD'] == 'PUT' || $_SERVER['REQUEST_METHOD'] == 'DELETE') {
            $request = Request::all();

            if (!isset($request['token']) && !Request::getCSRFToken()) {
                throw new RouteException(ExceptionMessages::CSRF_TOKEN_NOT_FOUND);
            }

            if (isset($request['token'])) {
                $token = $request['token'];
            } elseif (Request::getCSRFToken()) {
                $token = Request::getCSRFToken();
            }

            if (!Csrf::checkToken($request['token'])) {
                throw new RouteException(ExceptionMessages::CSRF_TOKEN_NOT_MATCHED);
            }
        }
    }