diff options
-rw-r--r-- | apps/admin_audit/lib/Actions/UserManagement.php | 26 | ||||
-rw-r--r-- | apps/admin_audit/lib/AppInfo/Application.php | 2 | ||||
-rw-r--r-- | apps/dav/lib/HookManager.php | 18 | ||||
-rw-r--r-- | lib/private/User/Manager.php | 3 | ||||
-rw-r--r-- | lib/private/User/Session.php | 3 | ||||
-rw-r--r-- | lib/public/IUserManager.php | 3 |
6 files changed, 55 insertions, 0 deletions
diff --git a/apps/admin_audit/lib/Actions/UserManagement.php b/apps/admin_audit/lib/Actions/UserManagement.php index 45250d4e708..9e015160773 100644 --- a/apps/admin_audit/lib/Actions/UserManagement.php +++ b/apps/admin_audit/lib/Actions/UserManagement.php @@ -51,6 +51,19 @@ class UserManagement extends Action { } /** + * Log assignments of users (typically user backends) + * + * @param string $uid + */ + public function announce(string $uid) { + $this->log( + 'UserID assgined: "%s"', + [ 'uid' => $uid ], + [ 'uid' ] + ); + } + + /** * Log deletion of users * * @param array $params @@ -66,6 +79,19 @@ class UserManagement extends Action { } /** + * Log unassignments of users (typically user backends, no data removed) + * + * @param string $uid + */ + public function revoke(string $uid) { + $this->log( + 'UserID unassigned: "%s"', + [ 'uid' => $uid ], + [ 'uid' ] + ); + } + + /** * Log enabling of users * * @param array $params diff --git a/apps/admin_audit/lib/AppInfo/Application.php b/apps/admin_audit/lib/AppInfo/Application.php index 5634a4a67b5..4f134ab308d 100644 --- a/apps/admin_audit/lib/AppInfo/Application.php +++ b/apps/admin_audit/lib/AppInfo/Application.php @@ -93,6 +93,8 @@ class Application extends App { /** @var IUserSession|Session $userSession */ $userSession = $this->getContainer()->getServer()->getUserSession(); $userSession->listen('\OC\User', 'postSetPassword', [$userActions, 'setPassword']); + $userSession->listen('\OC\User', 'announceUser', [$userActions, 'announce']); + $userSession->listen('\OC\User', 'postRevokeUser', [$userActions, 'revoke']); } protected function groupHooks(ILogger $logger) { diff --git a/apps/dav/lib/HookManager.php b/apps/dav/lib/HookManager.php index 57b176213e0..a887c6c4387 100644 --- a/apps/dav/lib/HookManager.php +++ b/apps/dav/lib/HookManager.php @@ -77,14 +77,22 @@ class HookManager { 'post_createUser', $this, 'postCreateUser'); + \OC::$server->getUserManager()->listen('\OC\User', 'announceUser', function ($uid) { + $this->postCreateUser(['uid' => $uid]); + }); Util::connectHook('OC_User', 'pre_deleteUser', $this, 'preDeleteUser'); + \OC::$server->getUserManager()->listen('\OC\User', 'preRevokeUser', [$this, 'preRevokeUser']); Util::connectHook('OC_User', 'post_deleteUser', $this, 'postDeleteUser'); + \OC::$server->getUserManager()->listen('\OC\User', 'postRevokeUser', function ($uid) { + $this->postDeleteUser(['uid' => $uid]); + }); + \OC::$server->getUserManager()->listen('\OC\User', 'postRevokeUser', [$this, 'postRevokeUser']); Util::connectHook('OC_User', 'changeUser', $this, @@ -103,6 +111,10 @@ class HookManager { $this->addressBooksToDelete = $this->cardDav->getUsersOwnAddressBooks('principals/users/' . $uid); } + public function preRevokeUser($uid) { + $this->usersToDelete[$uid] = $this->userManager->get($uid); + } + public function postDeleteUser($params) { $uid = $params['uid']; if (isset($this->usersToDelete[$uid])){ @@ -119,6 +131,12 @@ class HookManager { } } + public function postRevokeUser($uid) { + if (isset($this->usersToDelete[$uid])){ + $this->syncService->deleteUser($this->usersToDelete[$uid]); + } + } + public function changeUser($params) { $user = $params['user']; $this->syncService->updateUser($user); diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php index abc7a45e6bc..85fe42c774f 100644 --- a/lib/private/User/Manager.php +++ b/lib/private/User/Manager.php @@ -50,6 +50,9 @@ use OCP\UserInterface; * - preCreateUser(string $uid, string $password) * - postCreateUser(\OC\User\User $user, string $password) * - change(\OC\User\User $user) + * - announceUser(string $uid) + * - preRevokeUser(string $uid) + * - postRevokeUser(string $uid) * * @package OC\User */ diff --git a/lib/private/User/Session.php b/lib/private/User/Session.php index 4ac8888cee1..41149255819 100644 --- a/lib/private/User/Session.php +++ b/lib/private/User/Session.php @@ -72,6 +72,9 @@ use Symfony\Component\EventDispatcher\GenericEvent; * - postDelete(\OC\User\User $user) * - preCreateUser(string $uid, string $password) * - postCreateUser(\OC\User\User $user) + * - announceUser(string $uid) + * - preRevokeUser(string $uid) + * - postRevokeUser(string $uid) * - preLogin(string $user, string $password) * - postLogin(\OC\User\User $user, string $password) * - preRememberedLogin(string $uid) diff --git a/lib/public/IUserManager.php b/lib/public/IUserManager.php index 163e8b5e73f..c8f59a95ccd 100644 --- a/lib/public/IUserManager.php +++ b/lib/public/IUserManager.php @@ -40,6 +40,9 @@ namespace OCP; * - postDelete(\OC\User\User $user) * - preCreateUser(string $uid, string $password) * - postCreateUser(\OC\User\User $user, string $password) + * - announceUser(string $uid) + * - preRevokeUser(string $uid) + * - postRevokeUser(string $uid) * * @package OC\User * @since 8.0.0 |