diff options
author | Thomas Citharel <tcit@tcit.fr> | 2023-03-13 09:57:55 +0100 |
---|---|---|
committer | Côme Chilliet <come.chilliet@nextcloud.com> | 2024-09-10 14:06:12 +0200 |
commit | f532d3b2861642b0bc7b70aed8b7f95706b24bb0 (patch) | |
tree | dc37f88287b01204951ef0a9a06cb3d77a56b896 /apps/admin_audit/lib/Actions | |
parent | 986a3d45f8fab60c8e7dddc7015bd60c6ee356d4 (diff) | |
download | nextcloud-server-f532d3b2861642b0bc7b70aed8b7f95706b24bb0.tar.gz nextcloud-server-f532d3b2861642b0bc7b70aed8b7f95706b24bb0.zip |
feat(admin_audit): Move admin_audit hooks to modern event listeners
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
Diffstat (limited to 'apps/admin_audit/lib/Actions')
-rw-r--r-- | apps/admin_audit/lib/Actions/AppManagement.php | 42 | ||||
-rw-r--r-- | apps/admin_audit/lib/Actions/Auth.php | 45 | ||||
-rw-r--r-- | apps/admin_audit/lib/Actions/Console.php | 28 | ||||
-rw-r--r-- | apps/admin_audit/lib/Actions/GroupManagement.php | 87 | ||||
-rw-r--r-- | apps/admin_audit/lib/Actions/Security.php | 60 | ||||
-rw-r--r-- | apps/admin_audit/lib/Actions/UserManagement.php | 80 |
6 files changed, 0 insertions, 342 deletions
diff --git a/apps/admin_audit/lib/Actions/AppManagement.php b/apps/admin_audit/lib/Actions/AppManagement.php deleted file mode 100644 index 44907c856da..00000000000 --- a/apps/admin_audit/lib/Actions/AppManagement.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -declare(strict_types=1); -/** - * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ -namespace OCA\AdminAudit\Actions; - -class AppManagement extends Action { - - /** - * @param string $appName - */ - public function enableApp(string $appName): void { - $this->log('App "%s" enabled', - ['app' => $appName], - ['app'] - ); - } - - /** - * @param string $appName - * @param string[] $groups - */ - public function enableAppForGroups(string $appName, array $groups): void { - $this->log('App "%1$s" enabled for groups: %2$s', - ['app' => $appName, 'groups' => implode(', ', $groups)], - ['app', 'groups'] - ); - } - - /** - * @param string $appName - */ - public function disableApp(string $appName): void { - $this->log('App "%s" disabled', - ['app' => $appName], - ['app'] - ); - } -} diff --git a/apps/admin_audit/lib/Actions/Auth.php b/apps/admin_audit/lib/Actions/Auth.php deleted file mode 100644 index 55a87cf170f..00000000000 --- a/apps/admin_audit/lib/Actions/Auth.php +++ /dev/null @@ -1,45 +0,0 @@ -<?php - -declare(strict_types=1); -/** - * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ -namespace OCA\AdminAudit\Actions; - -/** - * Class Auth logs all auth related actions - * - * @package OCA\AdminAudit\Actions - */ -class Auth extends Action { - public function loginAttempt(array $params): void { - $this->log( - 'Login attempt: "%s"', - $params, - [ - 'uid', - ], - true - ); - } - - public function loginSuccessful(array $params): void { - $this->log( - 'Login successful: "%s"', - $params, - [ - 'uid', - ], - true - ); - } - - public function logout(array $params): void { - $this->log( - 'Logout occurred', - [], - [] - ); - } -} diff --git a/apps/admin_audit/lib/Actions/Console.php b/apps/admin_audit/lib/Actions/Console.php deleted file mode 100644 index a41fa88bdad..00000000000 --- a/apps/admin_audit/lib/Actions/Console.php +++ /dev/null @@ -1,28 +0,0 @@ -<?php - -declare(strict_types=1); -/** - * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ -namespace OCA\AdminAudit\Actions; - -class Console extends Action { - /** - * @param array $arguments - */ - public function runCommand(array $arguments): void { - if (!isset($arguments[1]) || $arguments[1] === '_completion') { - // Don't log autocompletion - return; - } - - // Remove `./occ` - array_shift($arguments); - - $this->log('Console command executed: %s', - ['arguments' => implode(' ', $arguments)], - ['arguments'] - ); - } -} diff --git a/apps/admin_audit/lib/Actions/GroupManagement.php b/apps/admin_audit/lib/Actions/GroupManagement.php deleted file mode 100644 index 8fb6a037fbf..00000000000 --- a/apps/admin_audit/lib/Actions/GroupManagement.php +++ /dev/null @@ -1,87 +0,0 @@ -<?php - -declare(strict_types=1); -/** - * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ -namespace OCA\AdminAudit\Actions; - -use OCP\IGroup; -use OCP\IUser; - -/** - * Class GroupManagement logs all group manager related events - * - * @package OCA\AdminAudit\Actions - */ -class GroupManagement extends Action { - - /** - * log add user to group event - * - * @param IGroup $group - * @param IUser $user - */ - public function addUser(IGroup $group, IUser $user): void { - $this->log('User "%s" added to group "%s"', - [ - 'group' => $group->getGID(), - 'user' => $user->getUID() - ], - [ - 'user', 'group' - ] - ); - } - - /** - * log remove user from group event - * - * @param IGroup $group - * @param IUser $user - */ - public function removeUser(IGroup $group, IUser $user): void { - $this->log('User "%s" removed from group "%s"', - [ - 'group' => $group->getGID(), - 'user' => $user->getUID() - ], - [ - 'user', 'group' - ] - ); - } - - /** - * log create group to group event - * - * @param IGroup $group - */ - public function createGroup(IGroup $group): void { - $this->log('Group created: "%s"', - [ - 'group' => $group->getGID() - ], - [ - 'group' - ] - ); - } - - /** - * log delete group to group event - * - * @param IGroup $group - */ - public function deleteGroup(IGroup $group): void { - $this->log('Group deleted: "%s"', - [ - 'group' => $group->getGID() - ], - [ - 'group' - ] - ); - } -} diff --git a/apps/admin_audit/lib/Actions/Security.php b/apps/admin_audit/lib/Actions/Security.php deleted file mode 100644 index 203090795fb..00000000000 --- a/apps/admin_audit/lib/Actions/Security.php +++ /dev/null @@ -1,60 +0,0 @@ -<?php - -declare(strict_types=1); -/** - * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors - * SPDX-License-Identifier: AGPL-3.0-or-later - */ -namespace OCA\AdminAudit\Actions; - -use OCP\Authentication\TwoFactorAuth\IProvider; -use OCP\IUser; - -/** - * Class Sharing logs the sharing actions - * - * @package OCA\AdminAudit\Actions - */ -class Security extends Action { - /** - * Logs failed twofactor challenge - */ - public function twofactorFailed(IUser $user, IProvider $provider): void { - $params = [ - 'displayName' => $user->getDisplayName(), - 'uid' => $user->getUID(), - 'provider' => $provider->getDisplayName(), - ]; - - $this->log( - 'Failed two factor attempt by user %s (%s) with provider %s', - $params, - [ - 'displayName', - 'uid', - 'provider', - ] - ); - } - - /** - * Logs successful twofactor challenge - */ - public function twofactorSuccess(IUser $user, IProvider $provider): void { - $params = [ - 'displayName' => $user->getDisplayName(), - 'uid' => $user->getUID(), - 'provider' => $provider->getDisplayName(), - ]; - - $this->log( - 'Successful two factor attempt by user %s (%s) with provider %s', - $params, - [ - 'displayName', - 'uid', - 'provider', - ] - ); - } -} diff --git a/apps/admin_audit/lib/Actions/UserManagement.php b/apps/admin_audit/lib/Actions/UserManagement.php index 25960197847..5b8b11f196b 100644 --- a/apps/admin_audit/lib/Actions/UserManagement.php +++ b/apps/admin_audit/lib/Actions/UserManagement.php @@ -7,28 +7,12 @@ declare(strict_types=1); */ namespace OCA\AdminAudit\Actions; -use OCP\IUser; - /** * Class UserManagement logs all user management related actions. * * @package OCA\AdminAudit\Actions */ class UserManagement extends Action { - /** - * Log creation of users - * - * @param array $params - */ - public function create(array $params): void { - $this->log( - 'User created: "%s"', - $params, - [ - 'uid', - ] - ); - } /** * Log assignments of users (typically user backends) @@ -44,21 +28,6 @@ class UserManagement extends Action { } /** - * Log deletion of users - * - * @param array $params - */ - public function delete(array $params): void { - $this->log( - 'User deleted: "%s"', - $params, - [ - 'uid', - ] - ); - } - - /** * Log unassignments of users (typically user backends, no data removed) * * @param string $uid @@ -70,53 +39,4 @@ class UserManagement extends Action { [ 'uid' ] ); } - - /** - * Log enabling of users - * - * @param array $params - */ - public function change(array $params): void { - switch ($params['feature']) { - case 'enabled': - $this->log( - $params['value'] === true - ? 'User enabled: "%s"' - : 'User disabled: "%s"', - ['user' => $params['user']->getUID()], - [ - 'user', - ] - ); - break; - case 'eMailAddress': - $this->log( - 'Email address changed for user %s', - ['user' => $params['user']->getUID()], - [ - 'user', - ] - ); - break; - } - } - - /** - * Logs changing of the user scope - * - * @param IUser $user - */ - public function setPassword(IUser $user): void { - if ($user->getBackendClassName() === 'Database') { - $this->log( - 'Password of user "%s" has been changed', - [ - 'user' => $user->getUID(), - ], - [ - 'user', - ] - ); - } - } } |