Returns true if the context has CSRF protection tokens.

@return boolean true, if the token is valid. false otherwise.
322079
public function hasCsrfProtectionTokens()
    {
        $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class);
        $csrfProtectionTokens = $sessionDataContainer->getCsrfProtectionTokens();
        return count($csrfProtectionTokens) > 0;
    }
497894
protected function verifyCsrfToken($token=null)
    {
        if ($this->options['csrfTokenEnabled']) {
            $token || $token = $this->request->getParam($this->options['csrfTokenName']);
            
            $data = static::getCsrfTokenData();
            
            $res = FormToken::instance()->verify($token, $data);
            
            if ($res['errcode']) {
                $this->stop()->errorInfo = $res;
            }
        }
        
        return $this->errorInfo;
    }
350430
public function isValidToken($src, $token)
    {
        $img_token = $this->getToken($src);
        if ($img_token === null) {
            return false;
        }

        if (!hash_equals($img_token, $token)) {
            \Yii::warning("Invalid token", __METHOD__);
            return false;
        }

        return true;
    }
1301791
public function hasTokens()
  {
    if (!is_writable(Remember::$tokensDir) || !is_dir(Remember::$tokensDir)) {
      $tokens = Remember::$tokensDir;
      return $this->exception("'$tokens' does not exist or is not writable by the web server");
    }
  }
1096717
public static function hasTokenStored(): bool
    {
        if (static::$token === null) {
            try {
                static::$token = static::getStoredToken();
            } catch (SecurityException $e) {
                // do nothing, so false will be returned
            }
        }

        return static::$token !== null;
    }
1225827
public function isAuthenticated()
    {
        try {
            $session = $this->sessionStorage->retrieveAccessToken($this->getServiceName());
            if (!$session) {
                return false;
            }
            return $session->getEndOfLife() > time();
        } catch (TokenNotFoundException $e) {
            return false;
        }
    }
1120690
private function isValidCsrfToken(Request $request): bool
    {
        $csrfTokenValue = $request->headers->get(self::CSRF_TOKEN_HEADER);

        return $this->csrfTokenManager->isTokenValid(
            new CsrfToken('authenticate', $csrfTokenValue)
        );
    }
904095
public function isValidVerifyTokenRequest()
    {
        if ($this->getRequest()->getMethod() !== 'GET') {
            return false;
        }

        $params = $this->getRequest()->getQueryParams();

        if (!isset($params['hub_verify_token'])) {
            return false;
        }

        return  $params['hub_verify_token'] === $this->verifyToken;
    }
277935
protected function isBranchToken()
	{
		return in_array($this->tokens[$this->i][0], [T_ELSE, T_ELSEIF, T_IF], true);
	}
879185
public function isValid()
    {
        // if this token was not validated before...
        if ($this->validated === null) {
            // get the token value
            $token = $this->field->getValue();

            if (!empty($_SESSION) && !empty($_SESSION['csrftokens'])) {
                // if the token is in the list of valid tokens, this field is valid!
                $key = array_search($token, $_SESSION['csrftokens']);
                if ($key !== false) {
                    // invalidate the token as it has already been used.
                    unset($_SESSION['csrftokens'][$key]);

                    $this->validated = true;
                } else {
                    $this->validated = false;
                }
            } else {
                $this->validated = false;
            }
        }

        return $this->validated;
    }
524946
@Override
    public boolean isValidRequest(Context context) {
        // Check if we are executing an unsafe method
        if (!isUnsafe(context)) {
            return true;
        }

        if (checkCsrfBypass(context)) {
            LOGGER.debug("Bypassing CSRF check for {} {}", context.route().getHttpMethod(), context.route().getUrl());
            return true;
        } else {
            String tokenFromRequest = extractTokenFromRequest(context);
            if (tokenFromRequest == null) {
                LOGGER.error("CSRF Check failed because there is no token in the incoming request headers");
                return false;
            }
            String tokenFromContent = extractTokenFromContent(context);
            if (tokenFromContent == null) {
                LOGGER.error("CSRF Check failed because we are unable to find a token in the incoming request query " +
                        "string or body");
                return false;
            }

            if (compareTokens(tokenFromRequest, tokenFromContent)) {
                return true;
            } else {
                LOGGER.error("CSRF Check failed because the given token is invalid");
                return false;
            }
        }
    }
348598
protected function checkToken()
    {
        $query = $this->query;
        $signature = $this->sign(
            $this->token,
            isset($query['timestamp']) ? $query['timestamp'] : '',
            isset($query['nonce']) ? $query['nonce'] : ''
        );
        return isset($query['signature']) && $signature === $query['signature'];
    }
146100
public static function csrfMetaTags()
    {
        $csrf = static::getCSRF();
        if ($csrf instanceof CSRF && $csrf->enableCsrfValidation) {
            return static::tag('meta', '', ['name' => 'csrf-param', 'content' => $csrf->csrfParam]) . "\n    "
            . static::tag('meta', '', ['name' => 'csrf-token', 'content' => $csrf->get()]) . "\n";
        } else {
            return '';
        }
    }
682406
public function getToken()
    {
        if(!isset($this->__token))
        {
            $token   = false;
            $request = $this->getObject('request');

            if($request->headers->has('X-XSRF-Token')) {
                $token = $request->headers->get('X-XSRF-Token');
            }

            if($request->headers->has('X-CSRF-Token')) {
                $token = $request->headers->get('X-CSRF-Token');
            }

            if($request->data->has('csrf_token')) {
                $token = $request->data->get('csrf_token', 'sha1');
            }

            $this->__token = $token;
        }

        return $this->__token;
    }
808305
private function isCurrentTokenValidInEnclosingContexts() {
        for ($contextKind = 0; $contextKind < ParseContext::Count; $contextKind++) {
            if ($this->isInParseContext($contextKind)) {
                if ($this->isValidListElement($contextKind, $this->getCurrentToken()) || $this->isListTerminator($contextKind)) {
                    return true;
                }
            }
        }
        return false;
    }
770196
public boolean isValidToken() {
        try {
//            Response response = wsBase.path(TEST_CONFIGS).request(MediaType.APPLICATION_JSON_TYPE).get();
//            return response.getStatusInfo().getFamily() == Response.Status.Family.SUCCESSFUL;

            LoadZone zone = getLoadZone(LoadZone.AMAZON_US_ASHBURN.uid);
            return zone == LoadZone.AMAZON_US_ASHBURN;
        } catch (Exception e) {
            log.info("API token validation failed: " + e);
        }
        return false;
    }
1181843
private function validateCsrfTokenInternal($clientSuppliedToken, $trueToken)
    {
        if (!is_string($clientSuppliedToken)) {
            return false;
        }

        $security = $this->app->security;

        return $security->unmaskToken($clientSuppliedToken) === $security->unmaskToken($trueToken);
    }