Obtains the CSRF token stored by the server for the corresponding
client. Returns null if undefined.

@param string $formName
@return null|string
333637
private function getStoredCsrfToken(string $formName): ?string
    {
        $csrfData = Session::getInstance()->read('__CSRF_TOKEN');
        if (is_null($csrfData)) {
            return null;
        }
        return isset($csrfData[$formName]) ? $csrfData[$formName] : null;
    }
997179
def get_csrf_token():
    """"""
    url = get_url("/simplecsrf/token.json")
    r = s.get(url=url, headers=DEFAULT_ORIGIN)
    return r.json()["token"]
60660
private function checkCsrfToken() {

		$tokenManager = new CsrfTokenManager();

		$token = new CsrfToken(
			'_' . $this->action . '_',
			$this->requestValues->get(self::CSRF_TOKEN_NAME)
		);

		return $tokenManager->isTokenValid($token);

	}
599554
protected function getTokenString()
    {
        $result = Request::post('_token', '');
        if ('' == $result) {
            $result = Request::get('_token', '');
        }

        if ('' == $result) {
            $result = isset($_SERVER['X-CSRF-TOKEN']) ? $_SERVER['X-CSRF-TOKEN'] : '';
        }

        return $result;
    }
792279
public function getHeader($sName)
    {
        $sName = strtolower($sName);
        foreach ($this->getAllHeaders() as $sKey => $mValue) {
            if (strtolower($sKey) === $sName) {
                return $mValue;
            }
        }
        return null;
    }
1096201
public function getResponsePlugin($sName)
    {
        if(array_key_exists($sName, $this->aResponsePlugins))
        {
            return $this->aResponsePlugins[$sName];
        }
        return null;
    }
281133
public static function getInputByNameSelector($formName, $fieldName)
    {
        $formSelector = static::getFormByNameSelector($formName);
        $fieldName = trim($fieldName);

        if (empty($formSelector) || empty($fieldName)) {
            return '';
        }

        return sprintf('%s input[name="%s"]', $formSelector, $fieldName);
    }
241845
protected function _token($token = null)
    {
        if ($token) {
            return $token;
        }

        $token = $this->_request()->data('token');
        if ($token) {
            return $token;
        }

        $token = $this->_request()->param('token');
        if ($token) {
            return $token;
        }

        return $this->_request()->query('token');
    }
837631
public function csrf($check = false, $force = false)
    {
        if ($this->config['csrf'] !== true) {
            return !empty($check) ? true : '';
        }

        if (session_id() == '' && $this->config['auto_session'] === true) {
            @session_start();
        }

        if ($check === false) {
            $current_token = $this->get_csrf_token();

            if (($current_token !== false && $force) || $current_token === false) {
                $token = sha1(uniqid(microtime(true), true));

                $_SESSION['phery'] = array(
                    'csrf' => $token
                );

                $token = base64_encode($token);
            } else {
                $token = base64_encode($_SESSION['phery']['csrf']);
            }

            return "<meta id=\"csrf-token\" name=\"csrf-token\" content=\"{$token}\" />\n";
        } else {
            if (empty($_SESSION['phery']['csrf'])) {
                return false;
            }

            return $_SESSION['phery']['csrf'] === base64_decode($check, true);
        }
    }
365484
public function verifyCsrfToken($inputVarName = 'csrfToken')
	{
		return (\Thinker\Http\Request::request($inputVarName, true, false) == $_SESSION['CSRF_TOKEN']);
	}
1278289
public function getToken($request = null)
    {
        $request = $request ?: $this->makeRequest();

        list($token) = sscanf($request->header($this->getAuthHeaderKey()), 'Bearer %s');
        if( ! $token) {
            $name = $this->getInputName();
            $token = $request->input($name);
        }

        return $token;
    }
574310
public function GetCsrf () {
		$session = & $this->getSession();
		list($name, $value) = $session->csrf;
		return (object) ['name' => $name, 'value' => $value];
	}
18792
protected function acquireSecurityTokenFromFederatedSTS($username, $password) {

        $response = Requests::get(str_replace('{username}', $username, self::$RealmUrlTemplate),null);
        $federatedStsUrl = $this->getFederatedAuthenticationInformation($response);

        if ($federatedStsUrl) {
          $message_id = md5(uniqid($username . '-' . time() . '-' . rand() , true));
          $data = $this->prepareSecurityFederatedTokenRequest($username, $password, $message_id, $federatedStsUrl->textContent);

          $headers = array();
          $headers['Content-Type'] = 'application/soap+xml';
          $response = Requests::post($federatedStsUrl->textContent, $headers, $data);

          $samlAssertion = $this->getSamlAssertion($response);

          if ($samlAssertion) {
            $samlAssertion_node = $samlAssertion->item(0);
            $data = $this->prepareRST2Request($samlAssertion_node);
            $response = Requests::post(self::$RST2Url, $headers, $data);
            $this->usingFederatedSTS = TRUE;

            return $response;
          }
        }

        return NULL;
    }
43992
public function getFormConfiguration($formClassName)
    {
        $formzConfiguration = $this->getExtensionConfiguration();

        return (isset($formzConfiguration['forms'][$formClassName]))
            ? $formzConfiguration['forms'][$formClassName]
            : [];
    }
1254875
private function getProvidedCsrfToken(): ?string
    {
        $token = $this->request->getParameter(self::REQUEST_TOKEN_VALUE);
        if (is_null($token)) {
            $token = isset($_SERVER[self::HEADER_TOKEN]) ? $_SERVER[self::HEADER_TOKEN] : null;
        }
        return $token;
    }
1101768
public function getFormCacheIdentifier($formClassName, $formName)
    {
        $shortClassName = end(explode('\\', $formClassName));

        return StringService::get()->sanitizeString($shortClassName . '-' . $formName);
    }
987401
protected function resetCsrfToken($token=null)
    {
        $token || $token = $this->request->getParam($this->options['csrfTokenName']);
        FormToken::instance()->reset($token);
    }