mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Restructured EventSubscriber Folder structure.
This commit is contained in:
parent
e8f83f188a
commit
26737f4b46
14 changed files with 76 additions and 25 deletions
|
@ -40,7 +40,7 @@ security:
|
|||
logout:
|
||||
path: logout
|
||||
target: homepage
|
||||
handlers: [App\EventSubscriber\LogoutListener]
|
||||
handlers: [App\EventSubscriber\LogSystem\LogoutLoggerHandler]
|
||||
|
||||
remember_me:
|
||||
secret: '%kernel.secret%'
|
||||
|
|
|
@ -48,7 +48,7 @@ services:
|
|||
resource: '../src/Controller'
|
||||
tags: ['controller.service_arguments']
|
||||
|
||||
App\EventSubscriber\MailFromListener:
|
||||
App\EventSubscriber\SetMailFromSubscriber:
|
||||
tags: ['kernel.event_subscriber']
|
||||
arguments:
|
||||
$email: '%sender_email%'
|
||||
|
@ -75,7 +75,7 @@ services:
|
|||
tags:
|
||||
- { name: "doctrine.orm.entity_listener" }
|
||||
|
||||
App\EventSubscriber\EventLoggerSubscriber:
|
||||
App\EventSubscriber\LogSystem\EventLoggerSubscriber:
|
||||
arguments:
|
||||
$save_changed_fields: '%env(bool:HISTORY_SAVE_CHANGED_FIELDS)%'
|
||||
$save_changed_data: '%env(bool:HISTORY_SAVE_CHANGED_DATA)%'
|
||||
|
@ -83,7 +83,7 @@ services:
|
|||
tags:
|
||||
- { name: 'doctrine.event_subscriber' }
|
||||
|
||||
App\EventSubscriber\MigrationListener:
|
||||
App\EventSubscriber\LogSystem\LogDBMigrationSubscriber:
|
||||
tags:
|
||||
- { name: 'doctrine.event_subscriber' }
|
||||
|
||||
|
@ -138,7 +138,7 @@ services:
|
|||
arguments:
|
||||
$demo_mode: '%demo_mode%'
|
||||
|
||||
App\EventSubscriber\TimezoneListener:
|
||||
App\EventSubscriber\UserSystem\SetUserTimezoneSubscriber:
|
||||
arguments:
|
||||
$timezone: '%timezone%'
|
||||
|
||||
|
|
|
@ -1,4 +1,22 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
|
||||
*
|
||||
* Copyright (C) 2019 - 2020 Jan Böhmer (https://github.com/jbtronics)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published
|
||||
* by the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
|
@ -21,7 +39,7 @@ declare(strict_types=1);
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\EventSubscriber;
|
||||
namespace App\EventSubscriber\LogSystem;
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
use App\Entity\Base\AbstractDBElement;
|
||||
|
@ -47,6 +65,10 @@ use Doctrine\Persistence\Event\LifecycleEventArgs;
|
|||
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
/**
|
||||
* This event subscriber write to event log when entities are changed, removed, created.
|
||||
* @package App\EventSubscriber\LogSystem
|
||||
*/
|
||||
class EventLoggerSubscriber implements EventSubscriber
|
||||
{
|
||||
/** @var array The given fields will not be saved, because they contain sensitive informations */
|
|
@ -40,7 +40,7 @@ declare(strict_types=1);
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
namespace App\EventSubscriber;
|
||||
namespace App\EventSubscriber\LogSystem;
|
||||
|
||||
use App\Entity\LogSystem\DatabaseUpdatedLogEntry;
|
||||
use App\Services\LogSystem\EventLogger;
|
||||
|
@ -48,7 +48,11 @@ use Doctrine\Common\EventSubscriber;
|
|||
use Doctrine\Migrations\Event\MigrationsEventArgs;
|
||||
use Doctrine\Migrations\Events;
|
||||
|
||||
class MigrationListener implements EventSubscriber
|
||||
/**
|
||||
* This subscriber logs databaseMigrations to Event log.
|
||||
* @package App\EventSubscriber
|
||||
*/
|
||||
class LogDBMigrationSubscriber implements EventSubscriber
|
||||
{
|
||||
protected $old_version = null;
|
||||
protected $new_version = null;
|
|
@ -40,7 +40,7 @@ declare(strict_types=1);
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
namespace App\EventSubscriber;
|
||||
namespace App\EventSubscriber\LogSystem;
|
||||
|
||||
use App\Entity\LogSystem\UserLogoutLogEntry;
|
||||
use App\Entity\UserSystem\User;
|
||||
|
@ -50,7 +50,11 @@ use Symfony\Component\HttpFoundation\Response;
|
|||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Http\Logout\LogoutHandlerInterface;
|
||||
|
||||
class LogoutListener implements LogoutHandlerInterface
|
||||
/**
|
||||
* This handler logs to event log, if a user logs out.
|
||||
* @package App\EventSubscriber\LogSystem
|
||||
*/
|
||||
class LogoutLoggerHandler implements LogoutHandlerInterface
|
||||
{
|
||||
protected $logger;
|
||||
protected $gpdr_compliance;
|
|
@ -18,7 +18,7 @@
|
|||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace App\EventSubscriber;
|
||||
namespace App\EventSubscriber\LogSystem;
|
||||
|
||||
|
||||
use App\Entity\LogSystem\SecurityEventLogEntry;
|
||||
|
@ -29,6 +29,10 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
/**
|
||||
* This subscriber writes entries to log if an security related event happens (e.g. the user changes its password).
|
||||
* @package App\EventSubscriber\LogSystem
|
||||
*/
|
||||
final class SecurityEventLoggerSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
|
|
@ -47,7 +47,11 @@ use Symfony\Component\Mailer\Event\MessageEvent;
|
|||
use Symfony\Component\Mime\Address;
|
||||
use Symfony\Component\Mime\Email;
|
||||
|
||||
final class MailFromListener implements EventSubscriberInterface
|
||||
/**
|
||||
* This subscriber set the "From" field for all sent email, based on the global configured sender name and email.
|
||||
* @package App\EventSubscriber
|
||||
*/
|
||||
final class SetMailFromSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
private $email;
|
||||
private $name;
|
|
@ -47,6 +47,10 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|||
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
|
||||
use Symfony\Component\HttpKernel\Event\ResponseEvent;
|
||||
|
||||
/**
|
||||
* This subscriber sets an Header in Debug mode that signals the Symfony Profiler to also update on Ajax requests.
|
||||
* @package App\EventSubscriber
|
||||
*/
|
||||
final class SymfonyDebugToolbarSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
private $kernel_debug;
|
||||
|
|
|
@ -40,7 +40,7 @@ declare(strict_types=1);
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
namespace App\EventSubscriber;
|
||||
namespace App\EventSubscriber\UserSystem;
|
||||
|
||||
use App\Entity\LogSystem\UserLoginLogEntry;
|
||||
use App\Entity\UserSystem\User;
|
||||
|
@ -52,9 +52,9 @@ use Symfony\Component\Security\Http\SecurityEvents;
|
|||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
* This event listener shows an login successful flash to the user after login.
|
||||
* This event listener shows an login successful flash to the user after login and write the login to event log.
|
||||
*/
|
||||
final class LoginSuccessListener implements EventSubscriberInterface
|
||||
final class LoginSuccessSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
private $translator;
|
||||
private $flashBag;
|
|
@ -40,7 +40,7 @@ declare(strict_types=1);
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
namespace App\EventSubscriber;
|
||||
namespace App\EventSubscriber\UserSystem;
|
||||
|
||||
use App\Entity\UserSystem\User;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
@ -50,7 +50,12 @@ use Symfony\Component\HttpKernel\KernelEvents;
|
|||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
final class LogoutOnDisabledUserListener implements EventSubscriberInterface
|
||||
/**
|
||||
* This subscriber is used to log out a disabled user, as soon as he to do an request.
|
||||
* It is not possible for him to login again, afterwards.
|
||||
* @package App\EventSubscriber\UserSystem
|
||||
*/
|
||||
final class LogoutDisabledUserSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
private $security;
|
||||
private $urlGenerator;
|
|
@ -40,7 +40,7 @@ declare(strict_types=1);
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
namespace App\EventSubscriber;
|
||||
namespace App\EventSubscriber\UserSystem;
|
||||
|
||||
use App\Entity\UserSystem\User;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|
@ -40,7 +40,7 @@ declare(strict_types=1);
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
namespace App\EventSubscriber;
|
||||
namespace App\EventSubscriber\UserSystem;
|
||||
|
||||
use App\Entity\UserSystem\U2FKey;
|
||||
use App\Entity\UserSystem\User;
|
||||
|
@ -55,7 +55,11 @@ use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
|
|||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
|
||||
|
||||
final class U2FRegistrationSubscriber implements EventSubscriberInterface
|
||||
/**
|
||||
* This subscriber is used to write U2F keys to DB, after user added them via GUI.
|
||||
* @package App\EventSubscriber\UserSystem
|
||||
*/
|
||||
final class RegisterU2FSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
private $em;
|
||||
|
|
@ -40,7 +40,7 @@ declare(strict_types=1);
|
|||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
namespace App\EventSubscriber;
|
||||
namespace App\EventSubscriber\UserSystem;
|
||||
|
||||
use App\Entity\UserSystem\User;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
@ -51,7 +51,7 @@ use Symfony\Component\Security\Core\Security;
|
|||
/**
|
||||
* The purpose of this event listener is to set the timezone to the one preferred by the user.
|
||||
*/
|
||||
final class TimezoneListener implements EventSubscriberInterface
|
||||
final class SetUserTimezoneSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
private $default_timezone;
|
||||
private $security;
|
|
@ -45,7 +45,7 @@ namespace App\Tests\EventSubscriber;
|
|||
use App\Entity\UserSystem\Group;
|
||||
use App\Entity\UserSystem\U2FKey;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\EventSubscriber\PasswordChangeNeededSubscriber;
|
||||
use App\EventSubscriber\UserSystem\PasswordChangeNeededSubscriber;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class PasswordChangeNeededSubscriberTest extends TestCase
|
||||
|
@ -57,11 +57,11 @@ class PasswordChangeNeededSubscriberTest extends TestCase
|
|||
|
||||
//A user without a group must not redirect
|
||||
$user->setGroup(null);
|
||||
$this->assertFalse(PasswordChangeNeededSubscriber::TFARedirectNeeded($user));
|
||||
$this->assertFalse(\App\EventSubscriber\UserSystem\PasswordChangeNeededSubscriber::TFARedirectNeeded($user));
|
||||
|
||||
//When the group does not enforce the redirect the user must not be redirected
|
||||
$user->setGroup($group);
|
||||
$this->assertFalse(PasswordChangeNeededSubscriber::TFARedirectNeeded($user));
|
||||
$this->assertFalse(\App\EventSubscriber\UserSystem\PasswordChangeNeededSubscriber::TFARedirectNeeded($user));
|
||||
|
||||
//The user must be redirected if the group enforces 2FA and it does not have a method
|
||||
$group->setEnforce2FA(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue