class CsrfRequestHeaderAccessCheck implements AccessCheckInterface (View source)

Access protection against CSRF attacks.

Constants

TOKEN_KEY

A string key that will used to designate the token used by this class.

Properties

protected SessionConfigurationInterface $sessionConfiguration

The session configuration.

protected CsrfTokenGenerator $csrfToken

The token generator.

Methods

__construct(SessionConfigurationInterface $session_configuration, CsrfTokenGenerator $csrf_token)

Constructs a new rest CSRF access check.

bool
applies(Route $route)

Declares whether the access check applies to a specific route or not.

access(Request $request, AccountInterface $account)

Checks access.

Details

__construct(SessionConfigurationInterface $session_configuration, CsrfTokenGenerator $csrf_token)

Constructs a new rest CSRF access check.

Parameters

SessionConfigurationInterface $session_configuration

The session configuration.

CsrfTokenGenerator $csrf_token

The token generator.

bool applies(Route $route)

Declares whether the access check applies to a specific route or not.

Parameters

Route $route

The route to consider attaching to.

Return Value

bool

TRUE if this access checker applies to this route.

AccessResultInterface access(Request $request, AccountInterface $account)

Checks access.

Parameters

Request $request

The request object.

AccountInterface $account

The currently logged in account.

Return Value

AccessResultInterface

The access result.