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

Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener Class Reference

This security listener listens to security.interactive_login event to: More...

Inheritance diagram for eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener:

## Public Member Functions
| __construct (Repository $repository, ConfigResolverInterface $configResolver, EventDispatcherInterface $eventDispatcher, TokenStorageInterface $tokenStorage, AuthorizationCheckerInterface $authorizationChecker, $fragmentPath='/_fragment')
| onInteractiveLogin (BaseInteractiveLoginEvent $event)
| Tries to retrieve a valid eZ user if authenticated user doesn't come from the repository (foreign user provider). More...
| checkSiteAccessPermission (BaseInteractiveLoginEvent $event)
| Throws an UnauthorizedSiteAccessException if current user doesn't have permission to current SiteAccess. More...
| onKernelRequest (GetResponseEvent $event)
| Throws an UnauthorizedSiteAccessException if current user doesn't have access to current SiteAccess. More...

## Static Public Member Functions
static | getSubscribedEvents ()

## Protected Member Functions
| getUser (UserInterface $originalUser, APIUser $apiUser)
| Returns new user object based on original user and provided API user. More...
| hasAccess (SiteAccess $siteAccess)
| Returns true if current user has access to given SiteAccess. More...

## Protected Attributes
| $repository
| $configResolver
| $eventDispatcher
| $tokenStorage
| $authorizationChecker
| $fragmentPath

## Private Member Functions
| isMasterRequest (Request $request, $requestType)
| Returns true if given request is considered as a master request. More...

## Detailed Description

This security listener listens to security.interactive_login event to:

- Give a chance to retrieve an eZ user when using multiple user providers
- Check if user can actually login to the current SiteAccess.

Also listens to kernel.request to:

- Check if current user (authenticated or not) can access to current SiteAccess

Definition at line 40 of file SecurityListener.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener::__construct | ( | Repository | $repository,
|  | ConfigResolverInterface | $configResolver,
|  | EventDispatcherInterface | $eventDispatcher,
|  | TokenStorageInterface | $tokenStorage,
|  | AuthorizationCheckerInterface | $authorizationChecker,
|  |  | $fragmentPath = `'/_fragment'`
| ) |  |

Definition at line 64 of file SecurityListener.php.

References eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\$authorizationChecker, eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\$configResolver, eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\$eventDispatcher, eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\$fragmentPath, eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\$repository, and eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\$tokenStorage.

## Member Function Documentation

## ◆ checkSiteAccessPermission()

eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener::checkSiteAccessPermission | ( | BaseInteractiveLoginEvent | $event | ) |

Throws an UnauthorizedSiteAccessException if current user doesn't have permission to current SiteAccess.

Parameters

  BaseInteractiveLoginEvent | $event |

Exceptions

Definition at line 161 of file SecurityListener.php.

References eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\hasAccess().

## ◆ getSubscribedEvents()

static eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener::getSubscribedEvents | ( |  | ) |
| static

Definition at line 80 of file SecurityListener.php.

## ◆ getUser()

eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener::getUser | ( | UserInterface | $originalUser,
|  | APIUser | $apiUser
| ) |  |
| protected

Returns new user object based on original user and provided API user.

One may want to override this method to use their own user class.

Parameters

  \Symfony\Component\Security\Core\User\UserInterface | $originalUser |
  \eZ\Publish\API\Repository\Values\User\User | $apiUser |

Returns
  \eZ\Publish\Core\MVC\Symfony\Security\UserInterface

Definition at line 149 of file SecurityListener.php.

Referenced by eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\onInteractiveLogin().

## ◆ hasAccess()

eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener::hasAccess | ( | SiteAccess | $siteAccess | ) |
| protected

Returns true if current user has access to given SiteAccess.

Parameters

  SiteAccess | $siteAccess |

Returns
  bool

Definition at line 238 of file SecurityListener.php.

Referenced by eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\checkSiteAccessPermission().

## ◆ isMasterRequest()

eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener::isMasterRequest | ( | Request | $request,
|  |  | $requestType
| ) |  |
| private

Returns true if given request is considered as a master request.

Fragments are considered as sub-requests (i.e. ESI, Hinclude...).

Parameters

  Request | $request |
  | $requestType |

Returns
  bool

Definition at line 219 of file SecurityListener.php.

Referenced by eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\onKernelRequest().

## ◆ onInteractiveLogin()

eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener::onInteractiveLogin | ( | BaseInteractiveLoginEvent | $event | ) |

Tries to retrieve a valid eZ user if authenticated user doesn't come from the repository (foreign user provider).

Will dispatch an event allowing listeners to return a valid eZ user for current authenticated user. Will by default let the repository load the anonymous user.

Parameters

  \Symfony\Component\Security\Http\Event\InteractiveLoginEvent | $event |

Definition at line 99 of file SecurityListener.php.

References eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\getUser(), and eZ\Publish\Core\MVC\Symfony\MVCEvents\INTERACTIVE_LOGIN.

## ◆ onKernelRequest()

eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener::onKernelRequest | ( | GetResponseEvent | $event | ) |

Throws an UnauthorizedSiteAccessException if current user doesn't have access to current SiteAccess.

Parameters

  GetResponseEvent | $event |

Exceptions

Definition at line 183 of file SecurityListener.php.

References eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\isMasterRequest().

## Member Data Documentation

## ◆ $authorizationChecker

eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener::$authorizationChecker
| protected

Definition at line 55 of file SecurityListener.php.

Referenced by eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\__construct().

## ◆ $configResolver

eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener::$configResolver
| protected

Definition at line 46 of file SecurityListener.php.

Referenced by eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\__construct().

## ◆ $eventDispatcher

eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener::$eventDispatcher
| protected

Definition at line 49 of file SecurityListener.php.

Referenced by eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\__construct().

## ◆ $fragmentPath

eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener::$fragmentPath
| protected

Definition at line 62 of file SecurityListener.php.

Referenced by eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\__construct().

## ◆ $repository

eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener::$repository
| protected

Definition at line 43 of file SecurityListener.php.

Referenced by eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\__construct().

## ◆ $tokenStorage

eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener::$tokenStorage
| protected

Definition at line 52 of file SecurityListener.php.

Referenced by eZ\Publish\Core\MVC\Symfony\Security\EventListener\SecurityListener\__construct().

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

- SecurityListener.php

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