Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Private Attributes | List of all members
eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener Class Reference
Inheritance diagram for eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener:

## Public Member Functions
| __construct (EventDispatcherInterface $eventDispatcher, $csrfEnabled, $csrfTokenIntention, CsrfTokenManagerInterface $csrfTokenManager=null)
| Note that CSRF provider needs to be optional as it will not be available when CSRF protection is disabled. More...
| onKernelRequest (GetResponseEvent $event)
| This method validates CSRF token if CSRF protection is enabled. More...

## Static Public Member Functions
static | getSubscribedEvents ()

## Public Attributes
const | CSRF_TOKEN_HEADER = 'X-CSRF-Token'
| Name of the HTTP header containing CSRF token. More...

## Protected Member Functions
| isMethodSafe ($method)
| isLoginRequest ($route)
| isSessionRoute ($route)
| Tests if a given $route is a session management one. More...
| checkCsrfToken (Request $request)
| Checks the validity of the request's csrf token header. More...

## Private Attributes
| $csrfTokenManager
| $eventDispatcher
| $csrfEnabled
| $csrfTokenIntention

## Detailed Description

Definition at line 19 of file CsrfListener.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener::__construct | ( | EventDispatcherInterface | $eventDispatcher,
|  |  | $csrfEnabled,
|  |  | $csrfTokenIntention,
|  | CsrfTokenManagerInterface | $csrfTokenManager = `null`
| ) |  |

Note that CSRF provider needs to be optional as it will not be available when CSRF protection is disabled.

Parameters

  \Symfony\Component\EventDispatcher\EventDispatcherInterface | $eventDispatcher |
  bool | $csrfEnabled |
  string | $csrfTokenIntention |
  CsrfTokenManagerInterface | null | $csrfTokenManager |

Definition at line 47 of file CsrfListener.php.

References eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener\$csrfEnabled, eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener\$csrfTokenIntention, eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener\$csrfTokenManager, and eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener\$eventDispatcher.

## Member Function Documentation

## ◆ checkCsrfToken()

eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener::checkCsrfToken | ( | Request | $request | ) |
| protected

Checks the validity of the request's csrf token header.

Parameters

  Request | $request |

Returns
  bool true/false if the token is valid/invalid, false if none was found in the request's headers.

Definition at line 154 of file CsrfListener.php.

Referenced by eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener\onKernelRequest().

## ◆ getSubscribedEvents()

static eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener::getSubscribedEvents | ( |  | ) |
| static

Returns
  array

Definition at line 62 of file CsrfListener.php.

## ◆ isLoginRequest()

eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener::isLoginRequest | ( |  | $route | ) |
| protected

Parameters

  string | $route |

Returns
  bool

Deprecated:
  Deprecated since 6.5. Use isSessionRoute() instead.

Definition at line 127 of file CsrfListener.php.

## ◆ isMethodSafe()

eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener::isMethodSafe | ( |  | $method | ) |
| protected

Parameters

  string | $method |

Returns
  bool

Definition at line 115 of file CsrfListener.php.

Referenced by eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener\onKernelRequest().

## ◆ isSessionRoute()

eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener::isSessionRoute | ( |  | $route | ) |
| protected

Tests if a given $route is a session management one.

Parameters

  string | $route |

Returns
  bool

Definition at line 139 of file CsrfListener.php.

Referenced by eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener\onKernelRequest().

## ◆ onKernelRequest()

eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener::onKernelRequest | ( | GetResponseEvent | $event | ) |

This method validates CSRF token if CSRF protection is enabled.

Parameters

  \Symfony\Component\HttpKernel\Event\GetResponseEvent | $event |

Exceptions

Definition at line 76 of file CsrfListener.php.

References eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener\checkCsrfToken(), eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener\isMethodSafe(), eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener\isSessionRoute(), and eZ\Bundle\EzPublishRestBundle\RestEvents\REST_CSRF_TOKEN_VALIDATED.

## Member Data Documentation

## ◆ $csrfEnabled

eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener::$csrfEnabled
| private

Definition at line 33 of file CsrfListener.php.

Referenced by eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener\__construct().

## ◆ $csrfTokenIntention

eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener::$csrfTokenIntention
| private

Definition at line 36 of file CsrfListener.php.

Referenced by eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener\__construct().

## ◆ $csrfTokenManager

eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener::$csrfTokenManager
| private

Definition at line 27 of file CsrfListener.php.

Referenced by eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener\__construct().

## ◆ $eventDispatcher

eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener::$eventDispatcher
| private

Definition at line 30 of file CsrfListener.php.

Referenced by eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener\__construct().

## ◆ CSRF_TOKEN_HEADER

const eZ\Bundle\EzPublishRestBundle\EventListener\CsrfListener::CSRF_TOKEN_HEADER = 'X-CSRF-Token'

Name of the HTTP header containing CSRF token.

Definition at line 24 of file CsrfListener.php.

The documentation for this class was generated from the following file:

- CsrfListener.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.