class CsrfAccessCheck in Flag 8.4
Proxy class to the core CSRF access chcker allowing anonymous requests.
As per https://www.drupal.org/node/2319205 this is OK and desired.
Hierarchy
- class \Drupal\flag\Access\CsrfAccessCheck implements AccessInterface
Expanded class hierarchy of CsrfAccessCheck
File
- src/
Access/ CsrfAccessCheck.php, line 18
Namespace
Drupal\flag\AccessView source
class CsrfAccessCheck implements AccessInterface {
/**
* @var \Drupal\Core\Access\CsrfAccessCheck
*/
protected $original;
/**
* @var \Drupal\Core\Session\AccountInterface
*/
protected $account;
/**
* CsrfAccessCheck constructor.
*
* @param \Drupal\Core\Access\CsrfAccessCheck $original
*/
public function __construct(OrignalCsrfAccessCheck $original, AccountInterface $account) {
$this->original = $original;
$this->account = $account;
}
/**
* Checks access based on a CSRF token for the request for auth users.
*
* @param \Symfony\Component\Routing\Route $route
* The route to check against.
* @param \Symfony\Component\HttpFoundation\Request $request
* The request object.
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The route match object.
*
* @return \Drupal\Core\Access\AccessResultInterface
* The access result, always allowed for anonymous users.
*/
public function access(Route $route, Request $request, RouteMatchInterface $route_match) {
// As the original returns AccessResult::allowedif the token validates,
// we do the same for anonymous.
return $this->account
->isAnonymous() ? AccessResult::allowed() : $this->original
->access($route, $request, $route_match);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CsrfAccessCheck:: |
protected | property | ||
CsrfAccessCheck:: |
protected | property | ||
CsrfAccessCheck:: |
public | function | Checks access based on a CSRF token for the request for auth users. | |
CsrfAccessCheck:: |
public | function | CsrfAccessCheck constructor. |