Returns the current CSRF protection token. A new one is created when needed, depending on the  configured CSRF
protection strategy.

@return string
@Flow\Session(autoStart=true)
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;
    }
779781
public function token()
    {
        if (empty($this->csrfToken) && !is_null($this->session)) {
            $this->csrfToken = $this->session->token();
        }

        return $this->hidden('_token', $this->csrfToken);
    }
93318
public static function token()
    {
        $token = null;

        if (self::has('server.HTTP_X_TOKEN')) {
            $token = self::get('server.HTTP_X_TOKEN', 'md5');
        }

        if (self::has('request._token')) {
            $token = self::get('request._token', 'md5');
        }

        return $token;
    }
1182961
public static function generateToken()
    {
        // Generate the token based on the current time, plus a random string.
        $token = time() . '.';

        // Start with an empty string.
        $length       = 32;
        $characterset = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890';

        // For the desired length, keep adding random characters from the character set.
        for ($i = 0; $i < $length; $i++) {
            $token .= $characterset[mt_rand(0, strlen($characterset) - 1)];
        }

        $sessions = [];

        if (isset($_SESSION['csrftokens'])) {
            $sessions = array_slice($_SESSION['csrftokens'], -50, 50);
        }

        // Add the token to the "token-basket", a place in which we store all the currently valid CSRF tokens.
        $sessions[] = $token;

        $_SESSION['csrftokens'] = $sessions;

        return $token;
    }
322079
public function hasCsrfProtectionTokens()
    {
        $sessionDataContainer = $this->objectManager->get(SessionDataContainer::class);
        $csrfProtectionTokens = $sessionDataContainer->getCsrfProtectionTokens();
        return count($csrfProtectionTokens) > 0;
    }
441510
public function getOAuthToken()
    {
        if (!$this->isStateless()) {
            return \Cache::get('oauth.temp');
        } else {
            /** @var TemporaryCredentials $temp */
            $temp = unserialize(\Cache::get('oauth_temp'));

            return $temp->getIdentifier();
        }
    }
1163016
public function getSessionChallengeToken()
    {
        $sRet = preg_replace('/[^a-z0-9]/i', '', $this->getVariable('sess_stoken'));
        if (!$sRet) {
            $this->_initNewSessionChallenge();
            $sRet = $this->getVariable('sess_stoken');
        }

        return $sRet;
    }
1179535
function csrf() {
		return Cache::instance()->
			exists(($this->sid?:session_id()).'.@',$data)?
				$data['csrf']:FALSE;
	}
21468
protected function verifyCsrfToken()
    {
        if (!Config::get('cms.enableCsrfProtection')) {
            return true;
        }

        if (in_array(Request::method(), ['HEAD', 'GET', 'OPTIONS'])) {
            return true;
        }

        $token = Request::input('_token') ?: Request::header('X-CSRF-TOKEN');

        if (!strlen($token)) {
            return false;
        }

        return hash_equals(
            Session::token(),
            $token
        );
    }
441713
public function getUserSessionToken()
    {
        if (($u = $this->getUserLoggedIn()) == null) {
            return null;
        }

        return isset($_SESSION['model-user-library-session-token']) ? $_SESSION['model-user-library-session-token'] : $_SESSION['model-user-library-session-token'] = $u->getUserToken();
    }
350059
public function getToken() : string {
        if (($this->token === null) || ($this->token->isExpired())) {
            $jwtBuilder = new Builder();
            $jwtBuilder->set('iss', $this->handlerPublicKey);
            $jwtBuilder->set('sub', $this->credentialPublicKey);

            $this->token = $jwtBuilder
                ->sign(new Sha256(), $this->handlerPrivateKey)
                ->getToken();
        }

        return (string) $this->token;
    }
104890
public function getToken(): string
    {
        return $this->cache->remember($this->tokenKey, $this->tokenTTL, function () {
            return $this->fetchToken();
        });
    }
840394
public function getToken()
    {
        if(isset($this->_tokens[$this->_position])) {
            return $this->_tokens[$this->_position];
        } else {
            return null;
        }
    }
994553
public function getToken(): string
    {
        if (empty($this->token)) {
            $this->setSize($this->token_size);
            $this->token = $this->generateRandomToken();
        }

        return $this->token;
    }
565452
public function createCsrfField()
    {
        $fieldName = Config::get('security.csrf.field_name');

        $input = new Input($this->form->expression('input'), [
            'name' => $fieldName,
            'value' => $this->createToken(),
            'type' => 'hidden'
        ]);

        return $input->execute();
    }
590827
protected static function getSuppliedCSRF()
    {
        $headers = function_exists('getallheaders') === true ? getallheaders() : [];

        $requestArguments = [];
        parse_str(file_get_contents('php://input'), $requestArguments);
        $requestArguments = array_merge($_POST, $requestArguments);

        if (array_key_exists(static::CSRF_TOKEN_HEADER, $headers) === true) {
            return $headers[static::CSRF_TOKEN_HEADER];
        } elseif (array_key_exists("csrf_token", $requestArguments) === true) {
            return $requestArguments['csrf_token'];
        } else {
            return null;
        }
    }
342120
private function getToken()
    {
        if (!$token = $this->storage->get('access_token')) {
            if (!$token = $this->storage->get('request_token')) {
                $token = new \stdClass();
                $token->oauth_token = null;
                $token->oauth_token_secret = null;
            }
        }
        return $token;
    }