@@ -6,47 +6,47 @@ |
||
| 6 | 6 | |
| 7 | 7 | class ComposerStaticInitAdminAudit |
| 8 | 8 | { |
| 9 | - public static $prefixLengthsPsr4 = array ( |
|
| 9 | + public static $prefixLengthsPsr4 = array( |
|
| 10 | 10 | 'O' => |
| 11 | - array ( |
|
| 11 | + array( |
|
| 12 | 12 | 'OCA\\AdminAudit\\' => 15, |
| 13 | 13 | ), |
| 14 | 14 | ); |
| 15 | 15 | |
| 16 | - public static $prefixDirsPsr4 = array ( |
|
| 16 | + public static $prefixDirsPsr4 = array( |
|
| 17 | 17 | 'OCA\\AdminAudit\\' => |
| 18 | - array ( |
|
| 19 | - 0 => __DIR__ . '/..' . '/../lib', |
|
| 18 | + array( |
|
| 19 | + 0 => __DIR__.'/..'.'/../lib', |
|
| 20 | 20 | ), |
| 21 | 21 | ); |
| 22 | 22 | |
| 23 | - public static $classMap = array ( |
|
| 24 | - 'Composer\\InstalledVersions' => __DIR__ . '/..' . '/composer/InstalledVersions.php', |
|
| 25 | - 'OCA\\AdminAudit\\Actions\\Action' => __DIR__ . '/..' . '/../lib/Actions/Action.php', |
|
| 26 | - 'OCA\\AdminAudit\\Actions\\Files' => __DIR__ . '/..' . '/../lib/Actions/Files.php', |
|
| 27 | - 'OCA\\AdminAudit\\Actions\\Sharing' => __DIR__ . '/..' . '/../lib/Actions/Sharing.php', |
|
| 28 | - 'OCA\\AdminAudit\\Actions\\TagManagement' => __DIR__ . '/..' . '/../lib/Actions/TagManagement.php', |
|
| 29 | - 'OCA\\AdminAudit\\Actions\\Trashbin' => __DIR__ . '/..' . '/../lib/Actions/Trashbin.php', |
|
| 30 | - 'OCA\\AdminAudit\\Actions\\Versions' => __DIR__ . '/..' . '/../lib/Actions/Versions.php', |
|
| 31 | - 'OCA\\AdminAudit\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php', |
|
| 32 | - 'OCA\\AdminAudit\\AuditLogger' => __DIR__ . '/..' . '/../lib/AuditLogger.php', |
|
| 33 | - 'OCA\\AdminAudit\\BackgroundJobs\\Rotate' => __DIR__ . '/..' . '/../lib/BackgroundJobs/Rotate.php', |
|
| 34 | - 'OCA\\AdminAudit\\IAuditLogger' => __DIR__ . '/..' . '/../lib/IAuditLogger.php', |
|
| 35 | - 'OCA\\AdminAudit\\Listener\\AppManagementEventListener' => __DIR__ . '/..' . '/../lib/Listener/AppManagementEventListener.php', |
|
| 36 | - 'OCA\\AdminAudit\\Listener\\AuthEventListener' => __DIR__ . '/..' . '/../lib/Listener/AuthEventListener.php', |
|
| 37 | - 'OCA\\AdminAudit\\Listener\\CacheEventListener' => __DIR__ . '/..' . '/../lib/Listener/CacheEventListener.php', |
|
| 38 | - 'OCA\\AdminAudit\\Listener\\ConsoleEventListener' => __DIR__ . '/..' . '/../lib/Listener/ConsoleEventListener.php', |
|
| 39 | - 'OCA\\AdminAudit\\Listener\\CriticalActionPerformedEventListener' => __DIR__ . '/..' . '/../lib/Listener/CriticalActionPerformedEventListener.php', |
|
| 40 | - 'OCA\\AdminAudit\\Listener\\FileEventListener' => __DIR__ . '/..' . '/../lib/Listener/FileEventListener.php', |
|
| 41 | - 'OCA\\AdminAudit\\Listener\\GroupManagementEventListener' => __DIR__ . '/..' . '/../lib/Listener/GroupManagementEventListener.php', |
|
| 42 | - 'OCA\\AdminAudit\\Listener\\SecurityEventListener' => __DIR__ . '/..' . '/../lib/Listener/SecurityEventListener.php', |
|
| 43 | - 'OCA\\AdminAudit\\Listener\\SharingEventListener' => __DIR__ . '/..' . '/../lib/Listener/SharingEventListener.php', |
|
| 44 | - 'OCA\\AdminAudit\\Listener\\UserManagementEventListener' => __DIR__ . '/..' . '/../lib/Listener/UserManagementEventListener.php', |
|
| 23 | + public static $classMap = array( |
|
| 24 | + 'Composer\\InstalledVersions' => __DIR__.'/..'.'/composer/InstalledVersions.php', |
|
| 25 | + 'OCA\\AdminAudit\\Actions\\Action' => __DIR__.'/..'.'/../lib/Actions/Action.php', |
|
| 26 | + 'OCA\\AdminAudit\\Actions\\Files' => __DIR__.'/..'.'/../lib/Actions/Files.php', |
|
| 27 | + 'OCA\\AdminAudit\\Actions\\Sharing' => __DIR__.'/..'.'/../lib/Actions/Sharing.php', |
|
| 28 | + 'OCA\\AdminAudit\\Actions\\TagManagement' => __DIR__.'/..'.'/../lib/Actions/TagManagement.php', |
|
| 29 | + 'OCA\\AdminAudit\\Actions\\Trashbin' => __DIR__.'/..'.'/../lib/Actions/Trashbin.php', |
|
| 30 | + 'OCA\\AdminAudit\\Actions\\Versions' => __DIR__.'/..'.'/../lib/Actions/Versions.php', |
|
| 31 | + 'OCA\\AdminAudit\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php', |
|
| 32 | + 'OCA\\AdminAudit\\AuditLogger' => __DIR__.'/..'.'/../lib/AuditLogger.php', |
|
| 33 | + 'OCA\\AdminAudit\\BackgroundJobs\\Rotate' => __DIR__.'/..'.'/../lib/BackgroundJobs/Rotate.php', |
|
| 34 | + 'OCA\\AdminAudit\\IAuditLogger' => __DIR__.'/..'.'/../lib/IAuditLogger.php', |
|
| 35 | + 'OCA\\AdminAudit\\Listener\\AppManagementEventListener' => __DIR__.'/..'.'/../lib/Listener/AppManagementEventListener.php', |
|
| 36 | + 'OCA\\AdminAudit\\Listener\\AuthEventListener' => __DIR__.'/..'.'/../lib/Listener/AuthEventListener.php', |
|
| 37 | + 'OCA\\AdminAudit\\Listener\\CacheEventListener' => __DIR__.'/..'.'/../lib/Listener/CacheEventListener.php', |
|
| 38 | + 'OCA\\AdminAudit\\Listener\\ConsoleEventListener' => __DIR__.'/..'.'/../lib/Listener/ConsoleEventListener.php', |
|
| 39 | + 'OCA\\AdminAudit\\Listener\\CriticalActionPerformedEventListener' => __DIR__.'/..'.'/../lib/Listener/CriticalActionPerformedEventListener.php', |
|
| 40 | + 'OCA\\AdminAudit\\Listener\\FileEventListener' => __DIR__.'/..'.'/../lib/Listener/FileEventListener.php', |
|
| 41 | + 'OCA\\AdminAudit\\Listener\\GroupManagementEventListener' => __DIR__.'/..'.'/../lib/Listener/GroupManagementEventListener.php', |
|
| 42 | + 'OCA\\AdminAudit\\Listener\\SecurityEventListener' => __DIR__.'/..'.'/../lib/Listener/SecurityEventListener.php', |
|
| 43 | + 'OCA\\AdminAudit\\Listener\\SharingEventListener' => __DIR__.'/..'.'/../lib/Listener/SharingEventListener.php', |
|
| 44 | + 'OCA\\AdminAudit\\Listener\\UserManagementEventListener' => __DIR__.'/..'.'/../lib/Listener/UserManagementEventListener.php', |
|
| 45 | 45 | ); |
| 46 | 46 | |
| 47 | 47 | public static function getInitializer(ClassLoader $loader) |
| 48 | 48 | { |
| 49 | - return \Closure::bind(function () use ($loader) { |
|
| 49 | + return \Closure::bind(function() use ($loader) { |
|
| 50 | 50 | $loader->prefixLengthsPsr4 = ComposerStaticInitAdminAudit::$prefixLengthsPsr4; |
| 51 | 51 | $loader->prefixDirsPsr4 = ComposerStaticInitAdminAudit::$prefixDirsPsr4; |
| 52 | 52 | $loader->classMap = ComposerStaticInitAdminAudit::$classMap; |
@@ -6,25 +6,25 @@ |
||
| 6 | 6 | $baseDir = $vendorDir; |
| 7 | 7 | |
| 8 | 8 | return array( |
| 9 | - 'Composer\\InstalledVersions' => $vendorDir . '/composer/InstalledVersions.php', |
|
| 10 | - 'OCA\\AdminAudit\\Actions\\Action' => $baseDir . '/../lib/Actions/Action.php', |
|
| 11 | - 'OCA\\AdminAudit\\Actions\\Files' => $baseDir . '/../lib/Actions/Files.php', |
|
| 12 | - 'OCA\\AdminAudit\\Actions\\Sharing' => $baseDir . '/../lib/Actions/Sharing.php', |
|
| 13 | - 'OCA\\AdminAudit\\Actions\\TagManagement' => $baseDir . '/../lib/Actions/TagManagement.php', |
|
| 14 | - 'OCA\\AdminAudit\\Actions\\Trashbin' => $baseDir . '/../lib/Actions/Trashbin.php', |
|
| 15 | - 'OCA\\AdminAudit\\Actions\\Versions' => $baseDir . '/../lib/Actions/Versions.php', |
|
| 16 | - 'OCA\\AdminAudit\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php', |
|
| 17 | - 'OCA\\AdminAudit\\AuditLogger' => $baseDir . '/../lib/AuditLogger.php', |
|
| 18 | - 'OCA\\AdminAudit\\BackgroundJobs\\Rotate' => $baseDir . '/../lib/BackgroundJobs/Rotate.php', |
|
| 19 | - 'OCA\\AdminAudit\\IAuditLogger' => $baseDir . '/../lib/IAuditLogger.php', |
|
| 20 | - 'OCA\\AdminAudit\\Listener\\AppManagementEventListener' => $baseDir . '/../lib/Listener/AppManagementEventListener.php', |
|
| 21 | - 'OCA\\AdminAudit\\Listener\\AuthEventListener' => $baseDir . '/../lib/Listener/AuthEventListener.php', |
|
| 22 | - 'OCA\\AdminAudit\\Listener\\CacheEventListener' => $baseDir . '/../lib/Listener/CacheEventListener.php', |
|
| 23 | - 'OCA\\AdminAudit\\Listener\\ConsoleEventListener' => $baseDir . '/../lib/Listener/ConsoleEventListener.php', |
|
| 24 | - 'OCA\\AdminAudit\\Listener\\CriticalActionPerformedEventListener' => $baseDir . '/../lib/Listener/CriticalActionPerformedEventListener.php', |
|
| 25 | - 'OCA\\AdminAudit\\Listener\\FileEventListener' => $baseDir . '/../lib/Listener/FileEventListener.php', |
|
| 26 | - 'OCA\\AdminAudit\\Listener\\GroupManagementEventListener' => $baseDir . '/../lib/Listener/GroupManagementEventListener.php', |
|
| 27 | - 'OCA\\AdminAudit\\Listener\\SecurityEventListener' => $baseDir . '/../lib/Listener/SecurityEventListener.php', |
|
| 28 | - 'OCA\\AdminAudit\\Listener\\SharingEventListener' => $baseDir . '/../lib/Listener/SharingEventListener.php', |
|
| 29 | - 'OCA\\AdminAudit\\Listener\\UserManagementEventListener' => $baseDir . '/../lib/Listener/UserManagementEventListener.php', |
|
| 9 | + 'Composer\\InstalledVersions' => $vendorDir.'/composer/InstalledVersions.php', |
|
| 10 | + 'OCA\\AdminAudit\\Actions\\Action' => $baseDir.'/../lib/Actions/Action.php', |
|
| 11 | + 'OCA\\AdminAudit\\Actions\\Files' => $baseDir.'/../lib/Actions/Files.php', |
|
| 12 | + 'OCA\\AdminAudit\\Actions\\Sharing' => $baseDir.'/../lib/Actions/Sharing.php', |
|
| 13 | + 'OCA\\AdminAudit\\Actions\\TagManagement' => $baseDir.'/../lib/Actions/TagManagement.php', |
|
| 14 | + 'OCA\\AdminAudit\\Actions\\Trashbin' => $baseDir.'/../lib/Actions/Trashbin.php', |
|
| 15 | + 'OCA\\AdminAudit\\Actions\\Versions' => $baseDir.'/../lib/Actions/Versions.php', |
|
| 16 | + 'OCA\\AdminAudit\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php', |
|
| 17 | + 'OCA\\AdminAudit\\AuditLogger' => $baseDir.'/../lib/AuditLogger.php', |
|
| 18 | + 'OCA\\AdminAudit\\BackgroundJobs\\Rotate' => $baseDir.'/../lib/BackgroundJobs/Rotate.php', |
|
| 19 | + 'OCA\\AdminAudit\\IAuditLogger' => $baseDir.'/../lib/IAuditLogger.php', |
|
| 20 | + 'OCA\\AdminAudit\\Listener\\AppManagementEventListener' => $baseDir.'/../lib/Listener/AppManagementEventListener.php', |
|
| 21 | + 'OCA\\AdminAudit\\Listener\\AuthEventListener' => $baseDir.'/../lib/Listener/AuthEventListener.php', |
|
| 22 | + 'OCA\\AdminAudit\\Listener\\CacheEventListener' => $baseDir.'/../lib/Listener/CacheEventListener.php', |
|
| 23 | + 'OCA\\AdminAudit\\Listener\\ConsoleEventListener' => $baseDir.'/../lib/Listener/ConsoleEventListener.php', |
|
| 24 | + 'OCA\\AdminAudit\\Listener\\CriticalActionPerformedEventListener' => $baseDir.'/../lib/Listener/CriticalActionPerformedEventListener.php', |
|
| 25 | + 'OCA\\AdminAudit\\Listener\\FileEventListener' => $baseDir.'/../lib/Listener/FileEventListener.php', |
|
| 26 | + 'OCA\\AdminAudit\\Listener\\GroupManagementEventListener' => $baseDir.'/../lib/Listener/GroupManagementEventListener.php', |
|
| 27 | + 'OCA\\AdminAudit\\Listener\\SecurityEventListener' => $baseDir.'/../lib/Listener/SecurityEventListener.php', |
|
| 28 | + 'OCA\\AdminAudit\\Listener\\SharingEventListener' => $baseDir.'/../lib/Listener/SharingEventListener.php', |
|
| 29 | + 'OCA\\AdminAudit\\Listener\\UserManagementEventListener' => $baseDir.'/../lib/Listener/UserManagementEventListener.php', |
|
| 30 | 30 | ); |
@@ -19,33 +19,33 @@ |
||
| 19 | 19 | * @template-implements IEventListener<CacheEntryInsertedEvent|CacheEntryRemovedEvent> |
| 20 | 20 | */ |
| 21 | 21 | class CacheEventListener extends Action implements IEventListener { |
| 22 | - public function handle(Event $event): void { |
|
| 23 | - if ($event instanceof CacheEntryInsertedEvent) { |
|
| 24 | - $this->entryInserted($event); |
|
| 25 | - } elseif ($event instanceof CacheEntryRemovedEvent) { |
|
| 26 | - $this->entryRemoved($event); |
|
| 27 | - } |
|
| 28 | - } |
|
| 22 | + public function handle(Event $event): void { |
|
| 23 | + if ($event instanceof CacheEntryInsertedEvent) { |
|
| 24 | + $this->entryInserted($event); |
|
| 25 | + } elseif ($event instanceof CacheEntryRemovedEvent) { |
|
| 26 | + $this->entryRemoved($event); |
|
| 27 | + } |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - private function entryInserted(CacheEntryInsertedEvent $event): void { |
|
| 31 | - $this->log('Cache entry inserted for fileid "%1$d", path "%2$s" on storageid "%3$d"', |
|
| 32 | - [ |
|
| 33 | - 'fileid' => $event->getFileId(), |
|
| 34 | - 'path' => $event->getPath(), |
|
| 35 | - 'storageid' => $event->getStorageId(), |
|
| 36 | - ], |
|
| 37 | - ['fileid', 'path', 'storageid'] |
|
| 38 | - ); |
|
| 39 | - } |
|
| 30 | + private function entryInserted(CacheEntryInsertedEvent $event): void { |
|
| 31 | + $this->log('Cache entry inserted for fileid "%1$d", path "%2$s" on storageid "%3$d"', |
|
| 32 | + [ |
|
| 33 | + 'fileid' => $event->getFileId(), |
|
| 34 | + 'path' => $event->getPath(), |
|
| 35 | + 'storageid' => $event->getStorageId(), |
|
| 36 | + ], |
|
| 37 | + ['fileid', 'path', 'storageid'] |
|
| 38 | + ); |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - private function entryRemoved(CacheEntryRemovedEvent $event): void { |
|
| 42 | - $this->log('Cache entry removed for fileid "%1$d", path "%2$s" on storageid "%3$d"', |
|
| 43 | - [ |
|
| 44 | - 'fileid' => $event->getFileId(), |
|
| 45 | - 'path' => $event->getPath(), |
|
| 46 | - 'storageid' => $event->getStorageId(), |
|
| 47 | - ], |
|
| 48 | - ['fileid', 'path', 'storageid'] |
|
| 49 | - ); |
|
| 50 | - } |
|
| 41 | + private function entryRemoved(CacheEntryRemovedEvent $event): void { |
|
| 42 | + $this->log('Cache entry removed for fileid "%1$d", path "%2$s" on storageid "%3$d"', |
|
| 43 | + [ |
|
| 44 | + 'fileid' => $event->getFileId(), |
|
| 45 | + 'path' => $event->getPath(), |
|
| 46 | + 'storageid' => $event->getStorageId(), |
|
| 47 | + ], |
|
| 48 | + ['fileid', 'path', 'storageid'] |
|
| 49 | + ); |
|
| 50 | + } |
|
| 51 | 51 | } |
@@ -75,158 +75,158 @@ |
||
| 75 | 75 | use Psr\Container\ContainerInterface; |
| 76 | 76 | |
| 77 | 77 | class Application extends App implements IBootstrap { |
| 78 | - public function __construct() { |
|
| 79 | - parent::__construct('admin_audit'); |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - public function register(IRegistrationContext $context): void { |
|
| 83 | - $context->registerService(IAuditLogger::class, function (ContainerInterface $c) { |
|
| 84 | - return new AuditLogger($c->get(ILogFactory::class), $c->get(IConfig::class)); |
|
| 85 | - }); |
|
| 86 | - |
|
| 87 | - $context->registerEventListener(CriticalActionPerformedEvent::class, CriticalActionPerformedEventListener::class); |
|
| 88 | - |
|
| 89 | - // User management events |
|
| 90 | - $context->registerEventListener(UserCreatedEvent::class, UserManagementEventListener::class); |
|
| 91 | - $context->registerEventListener(UserDeletedEvent::class, UserManagementEventListener::class); |
|
| 92 | - $context->registerEventListener(UserChangedEvent::class, UserManagementEventListener::class); |
|
| 93 | - $context->registerEventListener(PasswordUpdatedEvent::class, UserManagementEventListener::class); |
|
| 94 | - $context->registerEventListener(UserIdAssignedEvent::class, UserManagementEventListener::class); |
|
| 95 | - $context->registerEventListener(UserIdUnassignedEvent::class, UserManagementEventListener::class); |
|
| 96 | - |
|
| 97 | - // Group management events |
|
| 98 | - $context->registerEventListener(UserAddedEvent::class, GroupManagementEventListener::class); |
|
| 99 | - $context->registerEventListener(UserRemovedEvent::class, GroupManagementEventListener::class); |
|
| 100 | - $context->registerEventListener(GroupCreatedEvent::class, GroupManagementEventListener::class); |
|
| 101 | - $context->registerEventListener(GroupDeletedEvent::class, GroupManagementEventListener::class); |
|
| 102 | - |
|
| 103 | - // Sharing events |
|
| 104 | - $context->registerEventListener(ShareCreatedEvent::class, SharingEventListener::class); |
|
| 105 | - $context->registerEventListener(ShareDeletedEvent::class, SharingEventListener::class); |
|
| 106 | - |
|
| 107 | - // Auth events |
|
| 108 | - $context->registerEventListener(BeforeUserLoggedInEvent::class, AuthEventListener::class); |
|
| 109 | - $context->registerEventListener(UserLoggedInWithCookieEvent::class, AuthEventListener::class); |
|
| 110 | - $context->registerEventListener(UserLoggedInEvent::class, AuthEventListener::class); |
|
| 111 | - $context->registerEventListener(BeforeUserLoggedOutEvent::class, AuthEventListener::class); |
|
| 112 | - $context->registerEventListener(AnyLoginFailedEvent::class, AuthEventListener::class); |
|
| 113 | - |
|
| 114 | - // File events |
|
| 115 | - $context->registerEventListener(BeforePreviewFetchedEvent::class, FileEventListener::class); |
|
| 116 | - $context->registerEventListener(VersionRestoredEvent::class, FileEventListener::class); |
|
| 117 | - |
|
| 118 | - // Security events |
|
| 119 | - $context->registerEventListener(TwoFactorProviderChallengePassed::class, SecurityEventListener::class); |
|
| 120 | - $context->registerEventListener(TwoFactorProviderChallengeFailed::class, SecurityEventListener::class); |
|
| 121 | - |
|
| 122 | - // App management events |
|
| 123 | - $context->registerEventListener(AppEnableEvent::class, AppManagementEventListener::class); |
|
| 124 | - $context->registerEventListener(AppDisableEvent::class, AppManagementEventListener::class); |
|
| 125 | - $context->registerEventListener(AppUpdateEvent::class, AppManagementEventListener::class); |
|
| 126 | - |
|
| 127 | - // Console events |
|
| 128 | - $context->registerEventListener(ConsoleEvent::class, ConsoleEventListener::class); |
|
| 129 | - |
|
| 130 | - // Cache events |
|
| 131 | - $context->registerEventListener(CacheEntryInsertedEvent::class, CacheEventListener::class); |
|
| 132 | - $context->registerEventListener(CacheEntryRemovedEvent::class, CacheEventListener::class); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - public function boot(IBootContext $context): void { |
|
| 136 | - /** @var IAuditLogger $logger */ |
|
| 137 | - $logger = $context->getAppContainer()->get(IAuditLogger::class); |
|
| 138 | - |
|
| 139 | - /* |
|
| 78 | + public function __construct() { |
|
| 79 | + parent::__construct('admin_audit'); |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + public function register(IRegistrationContext $context): void { |
|
| 83 | + $context->registerService(IAuditLogger::class, function (ContainerInterface $c) { |
|
| 84 | + return new AuditLogger($c->get(ILogFactory::class), $c->get(IConfig::class)); |
|
| 85 | + }); |
|
| 86 | + |
|
| 87 | + $context->registerEventListener(CriticalActionPerformedEvent::class, CriticalActionPerformedEventListener::class); |
|
| 88 | + |
|
| 89 | + // User management events |
|
| 90 | + $context->registerEventListener(UserCreatedEvent::class, UserManagementEventListener::class); |
|
| 91 | + $context->registerEventListener(UserDeletedEvent::class, UserManagementEventListener::class); |
|
| 92 | + $context->registerEventListener(UserChangedEvent::class, UserManagementEventListener::class); |
|
| 93 | + $context->registerEventListener(PasswordUpdatedEvent::class, UserManagementEventListener::class); |
|
| 94 | + $context->registerEventListener(UserIdAssignedEvent::class, UserManagementEventListener::class); |
|
| 95 | + $context->registerEventListener(UserIdUnassignedEvent::class, UserManagementEventListener::class); |
|
| 96 | + |
|
| 97 | + // Group management events |
|
| 98 | + $context->registerEventListener(UserAddedEvent::class, GroupManagementEventListener::class); |
|
| 99 | + $context->registerEventListener(UserRemovedEvent::class, GroupManagementEventListener::class); |
|
| 100 | + $context->registerEventListener(GroupCreatedEvent::class, GroupManagementEventListener::class); |
|
| 101 | + $context->registerEventListener(GroupDeletedEvent::class, GroupManagementEventListener::class); |
|
| 102 | + |
|
| 103 | + // Sharing events |
|
| 104 | + $context->registerEventListener(ShareCreatedEvent::class, SharingEventListener::class); |
|
| 105 | + $context->registerEventListener(ShareDeletedEvent::class, SharingEventListener::class); |
|
| 106 | + |
|
| 107 | + // Auth events |
|
| 108 | + $context->registerEventListener(BeforeUserLoggedInEvent::class, AuthEventListener::class); |
|
| 109 | + $context->registerEventListener(UserLoggedInWithCookieEvent::class, AuthEventListener::class); |
|
| 110 | + $context->registerEventListener(UserLoggedInEvent::class, AuthEventListener::class); |
|
| 111 | + $context->registerEventListener(BeforeUserLoggedOutEvent::class, AuthEventListener::class); |
|
| 112 | + $context->registerEventListener(AnyLoginFailedEvent::class, AuthEventListener::class); |
|
| 113 | + |
|
| 114 | + // File events |
|
| 115 | + $context->registerEventListener(BeforePreviewFetchedEvent::class, FileEventListener::class); |
|
| 116 | + $context->registerEventListener(VersionRestoredEvent::class, FileEventListener::class); |
|
| 117 | + |
|
| 118 | + // Security events |
|
| 119 | + $context->registerEventListener(TwoFactorProviderChallengePassed::class, SecurityEventListener::class); |
|
| 120 | + $context->registerEventListener(TwoFactorProviderChallengeFailed::class, SecurityEventListener::class); |
|
| 121 | + |
|
| 122 | + // App management events |
|
| 123 | + $context->registerEventListener(AppEnableEvent::class, AppManagementEventListener::class); |
|
| 124 | + $context->registerEventListener(AppDisableEvent::class, AppManagementEventListener::class); |
|
| 125 | + $context->registerEventListener(AppUpdateEvent::class, AppManagementEventListener::class); |
|
| 126 | + |
|
| 127 | + // Console events |
|
| 128 | + $context->registerEventListener(ConsoleEvent::class, ConsoleEventListener::class); |
|
| 129 | + |
|
| 130 | + // Cache events |
|
| 131 | + $context->registerEventListener(CacheEntryInsertedEvent::class, CacheEventListener::class); |
|
| 132 | + $context->registerEventListener(CacheEntryRemovedEvent::class, CacheEventListener::class); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + public function boot(IBootContext $context): void { |
|
| 136 | + /** @var IAuditLogger $logger */ |
|
| 137 | + $logger = $context->getAppContainer()->get(IAuditLogger::class); |
|
| 138 | + |
|
| 139 | + /* |
|
| 140 | 140 | * TODO: once the hooks are migrated to lazy events, this should be done |
| 141 | 141 | * in \OCA\AdminAudit\AppInfo\Application::register |
| 142 | 142 | */ |
| 143 | - $this->registerLegacyHooks($logger, $context->getServerContainer()); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * Register hooks in order to log them |
|
| 148 | - */ |
|
| 149 | - private function registerLegacyHooks(IAuditLogger $logger, ContainerInterface $serverContainer): void { |
|
| 150 | - /** @var IEventDispatcher $eventDispatcher */ |
|
| 151 | - $eventDispatcher = $serverContainer->get(IEventDispatcher::class); |
|
| 152 | - $this->sharingLegacyHooks($logger); |
|
| 153 | - $this->fileHooks($logger, $eventDispatcher); |
|
| 154 | - $this->trashbinHooks($logger); |
|
| 155 | - $this->versionsHooks($logger); |
|
| 156 | - $this->tagHooks($logger, $eventDispatcher); |
|
| 157 | - } |
|
| 158 | - |
|
| 159 | - private function sharingLegacyHooks(IAuditLogger $logger): void { |
|
| 160 | - $shareActions = new Sharing($logger); |
|
| 161 | - |
|
| 162 | - Util::connectHook(Share::class, 'post_update_permissions', $shareActions, 'updatePermissions'); |
|
| 163 | - Util::connectHook(Share::class, 'post_update_password', $shareActions, 'updatePassword'); |
|
| 164 | - Util::connectHook(Share::class, 'post_set_expiration_date', $shareActions, 'updateExpirationDate'); |
|
| 165 | - Util::connectHook(Share::class, 'share_link_access', $shareActions, 'shareAccessed'); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - private function tagHooks(IAuditLogger $logger, |
|
| 169 | - IEventDispatcher $eventDispatcher): void { |
|
| 170 | - $eventDispatcher->addListener(ManagerEvent::EVENT_CREATE, function (ManagerEvent $event) use ($logger): void { |
|
| 171 | - $tagActions = new TagManagement($logger); |
|
| 172 | - $tagActions->createTag($event->getTag()); |
|
| 173 | - }); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - private function fileHooks(IAuditLogger $logger, IEventDispatcher $eventDispatcher): void { |
|
| 177 | - $fileActions = new Files($logger); |
|
| 178 | - |
|
| 179 | - $eventDispatcher->addListener( |
|
| 180 | - NodeRenamedEvent::class, |
|
| 181 | - function (NodeRenamedEvent $event) use ($fileActions): void { |
|
| 182 | - $fileActions->afterRename($event); |
|
| 183 | - } |
|
| 184 | - ); |
|
| 185 | - |
|
| 186 | - $eventDispatcher->addListener( |
|
| 187 | - NodeCreatedEvent::class, |
|
| 188 | - function (NodeCreatedEvent $event) use ($fileActions): void { |
|
| 189 | - $fileActions->create($event); |
|
| 190 | - } |
|
| 191 | - ); |
|
| 192 | - |
|
| 193 | - $eventDispatcher->addListener( |
|
| 194 | - NodeCopiedEvent::class, |
|
| 195 | - function (NodeCopiedEvent $event) use ($fileActions): void { |
|
| 196 | - $fileActions->copy($event); |
|
| 197 | - } |
|
| 198 | - ); |
|
| 199 | - |
|
| 200 | - $eventDispatcher->addListener( |
|
| 201 | - NodeWrittenEvent::class, |
|
| 202 | - function (NodeWrittenEvent $event) use ($fileActions): void { |
|
| 203 | - $fileActions->write($event); |
|
| 204 | - } |
|
| 205 | - ); |
|
| 206 | - |
|
| 207 | - $eventDispatcher->addListener( |
|
| 208 | - BeforeNodeReadEvent::class, |
|
| 209 | - function (BeforeNodeReadEvent $event) use ($fileActions): void { |
|
| 210 | - $fileActions->read($event); |
|
| 211 | - } |
|
| 212 | - ); |
|
| 213 | - |
|
| 214 | - $eventDispatcher->addListener( |
|
| 215 | - BeforeNodeDeletedEvent::class, |
|
| 216 | - function (BeforeNodeDeletedEvent $event) use ($fileActions): void { |
|
| 217 | - $fileActions->delete($event); |
|
| 218 | - } |
|
| 219 | - ); |
|
| 220 | - } |
|
| 221 | - |
|
| 222 | - private function versionsHooks(IAuditLogger $logger): void { |
|
| 223 | - $versionsActions = new Versions($logger); |
|
| 224 | - Util::connectHook('\OCP\Versions', 'delete', $versionsActions, 'delete'); |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - private function trashbinHooks(IAuditLogger $logger): void { |
|
| 228 | - $trashActions = new Trashbin($logger); |
|
| 229 | - Util::connectHook('\OCP\Trashbin', 'preDelete', $trashActions, 'delete'); |
|
| 230 | - Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', $trashActions, 'restore'); |
|
| 231 | - } |
|
| 143 | + $this->registerLegacyHooks($logger, $context->getServerContainer()); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * Register hooks in order to log them |
|
| 148 | + */ |
|
| 149 | + private function registerLegacyHooks(IAuditLogger $logger, ContainerInterface $serverContainer): void { |
|
| 150 | + /** @var IEventDispatcher $eventDispatcher */ |
|
| 151 | + $eventDispatcher = $serverContainer->get(IEventDispatcher::class); |
|
| 152 | + $this->sharingLegacyHooks($logger); |
|
| 153 | + $this->fileHooks($logger, $eventDispatcher); |
|
| 154 | + $this->trashbinHooks($logger); |
|
| 155 | + $this->versionsHooks($logger); |
|
| 156 | + $this->tagHooks($logger, $eventDispatcher); |
|
| 157 | + } |
|
| 158 | + |
|
| 159 | + private function sharingLegacyHooks(IAuditLogger $logger): void { |
|
| 160 | + $shareActions = new Sharing($logger); |
|
| 161 | + |
|
| 162 | + Util::connectHook(Share::class, 'post_update_permissions', $shareActions, 'updatePermissions'); |
|
| 163 | + Util::connectHook(Share::class, 'post_update_password', $shareActions, 'updatePassword'); |
|
| 164 | + Util::connectHook(Share::class, 'post_set_expiration_date', $shareActions, 'updateExpirationDate'); |
|
| 165 | + Util::connectHook(Share::class, 'share_link_access', $shareActions, 'shareAccessed'); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + private function tagHooks(IAuditLogger $logger, |
|
| 169 | + IEventDispatcher $eventDispatcher): void { |
|
| 170 | + $eventDispatcher->addListener(ManagerEvent::EVENT_CREATE, function (ManagerEvent $event) use ($logger): void { |
|
| 171 | + $tagActions = new TagManagement($logger); |
|
| 172 | + $tagActions->createTag($event->getTag()); |
|
| 173 | + }); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + private function fileHooks(IAuditLogger $logger, IEventDispatcher $eventDispatcher): void { |
|
| 177 | + $fileActions = new Files($logger); |
|
| 178 | + |
|
| 179 | + $eventDispatcher->addListener( |
|
| 180 | + NodeRenamedEvent::class, |
|
| 181 | + function (NodeRenamedEvent $event) use ($fileActions): void { |
|
| 182 | + $fileActions->afterRename($event); |
|
| 183 | + } |
|
| 184 | + ); |
|
| 185 | + |
|
| 186 | + $eventDispatcher->addListener( |
|
| 187 | + NodeCreatedEvent::class, |
|
| 188 | + function (NodeCreatedEvent $event) use ($fileActions): void { |
|
| 189 | + $fileActions->create($event); |
|
| 190 | + } |
|
| 191 | + ); |
|
| 192 | + |
|
| 193 | + $eventDispatcher->addListener( |
|
| 194 | + NodeCopiedEvent::class, |
|
| 195 | + function (NodeCopiedEvent $event) use ($fileActions): void { |
|
| 196 | + $fileActions->copy($event); |
|
| 197 | + } |
|
| 198 | + ); |
|
| 199 | + |
|
| 200 | + $eventDispatcher->addListener( |
|
| 201 | + NodeWrittenEvent::class, |
|
| 202 | + function (NodeWrittenEvent $event) use ($fileActions): void { |
|
| 203 | + $fileActions->write($event); |
|
| 204 | + } |
|
| 205 | + ); |
|
| 206 | + |
|
| 207 | + $eventDispatcher->addListener( |
|
| 208 | + BeforeNodeReadEvent::class, |
|
| 209 | + function (BeforeNodeReadEvent $event) use ($fileActions): void { |
|
| 210 | + $fileActions->read($event); |
|
| 211 | + } |
|
| 212 | + ); |
|
| 213 | + |
|
| 214 | + $eventDispatcher->addListener( |
|
| 215 | + BeforeNodeDeletedEvent::class, |
|
| 216 | + function (BeforeNodeDeletedEvent $event) use ($fileActions): void { |
|
| 217 | + $fileActions->delete($event); |
|
| 218 | + } |
|
| 219 | + ); |
|
| 220 | + } |
|
| 221 | + |
|
| 222 | + private function versionsHooks(IAuditLogger $logger): void { |
|
| 223 | + $versionsActions = new Versions($logger); |
|
| 224 | + Util::connectHook('\OCP\Versions', 'delete', $versionsActions, 'delete'); |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + private function trashbinHooks(IAuditLogger $logger): void { |
|
| 228 | + $trashActions = new Trashbin($logger); |
|
| 229 | + Util::connectHook('\OCP\Trashbin', 'preDelete', $trashActions, 'delete'); |
|
| 230 | + Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', $trashActions, 'restore'); |
|
| 231 | + } |
|
| 232 | 232 | } |