function CsrfTokenController::csrfToken

Same name in other branches
  1. 9 core/modules/system/src/Controller/CsrfTokenController.php \Drupal\system\Controller\CsrfTokenController::csrfToken()
  2. 10 core/modules/system/src/Controller/CsrfTokenController.php \Drupal\system\Controller\CsrfTokenController::csrfToken()
  3. 11.x core/modules/system/src/Controller/CsrfTokenController.php \Drupal\system\Controller\CsrfTokenController::csrfToken()

Returns a CSRF protecting session token.

Return value

\Symfony\Component\HttpFoundation\Response The response object.

2 string references to 'CsrfTokenController::csrfToken'
rest.routing.yml in core/modules/rest/rest.routing.yml
core/modules/rest/rest.routing.yml
system.routing.yml in core/modules/system/system.routing.yml
core/modules/system/system.routing.yml

File

core/modules/system/src/Controller/CsrfTokenController.php, line 48

Class

CsrfTokenController
Returns responses for CSRF token routes.

Namespace

Drupal\system\Controller

Code

public function csrfToken() {
    return new Response($this->tokenGenerator
        ->get(CsrfRequestHeaderAccessCheck::TOKEN_KEY), 200, [
        'Content-Type' => 'text/plain',
    ]);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.