class CsrfAccessCheck implements AccessInterface (View source)

Allows access to routes to be controlled by a '_csrf_token' parameter.

To use this check, add a "token" GET parameter to URLs of which the value is a token generated by \Drupal::csrfToken()->get() using the same value as the "_csrf_token" parameter in the route.

Properties

protected CsrfTokenGenerator $csrfToken

The CSRF token generator.

Methods

__construct(CsrfTokenGenerator $csrf_token)

Constructs a CsrfAccessCheck object.

access(Route $route, Request $request, RouteMatchInterface $route_match)

Checks access based on a CSRF token for the request.

Details

__construct(CsrfTokenGenerator $csrf_token)

Constructs a CsrfAccessCheck object.

Parameters

CsrfTokenGenerator $csrf_token

The CSRF token generator.

AccessResultInterface access(Route $route, Request $request, RouteMatchInterface $route_match)

Checks access based on a CSRF token for the request.

Parameters

Route $route

The route to check against.

Request $request

The request object.

RouteMatchInterface $route_match

The route match object.

Return Value

AccessResultInterface

The access result.