2016-06-08 16:25:44 +03:00
|
|
|
<?php
|
2019-12-03 21:57:53 +03:00
|
|
|
|
2018-03-10 21:40:19 +03:00
|
|
|
declare(strict_types=1);
|
2019-12-03 21:57:53 +03:00
|
|
|
|
2016-06-08 16:25:44 +03:00
|
|
|
/**
|
|
|
|
* @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
|
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
|
2016-07-21 17:49:16 +03:00
|
|
|
* @author Bjoern Schiessle <bjoern@schiessle.org>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
|
2016-07-21 17:49:16 +03:00
|
|
|
* @author Lukas Reschke <lukas@statuscode.ch>
|
|
|
|
*
|
2016-06-08 16:25:44 +03:00
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* 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
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2016-06-08 16:25:44 +03:00
|
|
|
*
|
|
|
|
*/
|
2017-07-01 12:28:03 +03:00
|
|
|
|
|
|
|
namespace OCA\AdminAudit\Actions;
|
|
|
|
|
2016-06-09 19:03:31 +03:00
|
|
|
use OCP\IUser;
|
2016-06-08 16:25:44 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class UserManagement logs all user management related actions.
|
|
|
|
*
|
2017-07-01 12:28:03 +03:00
|
|
|
* @package OCA\AdminAudit\Actions
|
2016-06-08 16:25:44 +03:00
|
|
|
*/
|
|
|
|
class UserManagement extends Action {
|
|
|
|
/**
|
|
|
|
* Log creation of users
|
|
|
|
*
|
|
|
|
* @param array $params
|
|
|
|
*/
|
|
|
|
public function create(array $params) {
|
|
|
|
$this->log(
|
|
|
|
'User created: "%s"',
|
|
|
|
$params,
|
|
|
|
[
|
|
|
|
'uid',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-03-15 16:43:59 +03:00
|
|
|
/**
|
|
|
|
* Log assignments of users (typically user backends)
|
|
|
|
*
|
|
|
|
* @param string $uid
|
|
|
|
*/
|
2018-03-19 17:23:30 +03:00
|
|
|
public function assign(string $uid) {
|
2018-03-15 16:43:59 +03:00
|
|
|
$this->log(
|
2018-03-19 17:23:30 +03:00
|
|
|
'UserID assigned: "%s"',
|
2018-03-15 16:43:59 +03:00
|
|
|
[ 'uid' => $uid ],
|
|
|
|
[ 'uid' ]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-06-08 16:25:44 +03:00
|
|
|
/**
|
|
|
|
* Log deletion of users
|
|
|
|
*
|
|
|
|
* @param array $params
|
|
|
|
*/
|
|
|
|
public function delete(array $params) {
|
|
|
|
$this->log(
|
|
|
|
'User deleted: "%s"',
|
|
|
|
$params,
|
|
|
|
[
|
|
|
|
'uid',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-03-15 16:43:59 +03:00
|
|
|
/**
|
|
|
|
* Log unassignments of users (typically user backends, no data removed)
|
|
|
|
*
|
|
|
|
* @param string $uid
|
|
|
|
*/
|
2018-03-19 17:23:30 +03:00
|
|
|
public function unassign(string $uid) {
|
2018-03-15 16:43:59 +03:00
|
|
|
$this->log(
|
|
|
|
'UserID unassigned: "%s"',
|
|
|
|
[ 'uid' => $uid ],
|
|
|
|
[ 'uid' ]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2017-04-25 18:18:56 +03:00
|
|
|
/**
|
|
|
|
* Log enabling of users
|
|
|
|
*
|
|
|
|
* @param array $params
|
|
|
|
*/
|
|
|
|
public function change(array $params) {
|
2020-04-10 15:19:56 +03:00
|
|
|
switch ($params['feature']) {
|
2018-08-14 18:06:57 +03:00
|
|
|
case 'enabled':
|
|
|
|
$this->log(
|
2019-08-07 18:50:59 +03:00
|
|
|
$params['value'] === true
|
|
|
|
? 'User enabled: "%s"'
|
|
|
|
: 'User disabled: "%s"',
|
2018-08-14 18:06:57 +03:00
|
|
|
['user' => $params['user']->getUID()],
|
|
|
|
[
|
|
|
|
'user',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case 'eMailAddress':
|
|
|
|
$this->log(
|
|
|
|
'Email address changed for user %s',
|
|
|
|
['user' => $params['user']->getUID()],
|
|
|
|
[
|
|
|
|
'user',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
break;
|
2017-04-25 18:18:56 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-08 16:25:44 +03:00
|
|
|
/**
|
|
|
|
* Logs changing of the user scope
|
|
|
|
*
|
2016-06-09 19:03:31 +03:00
|
|
|
* @param IUser $user
|
2016-06-08 16:25:44 +03:00
|
|
|
*/
|
2016-06-09 19:03:31 +03:00
|
|
|
public function setPassword(IUser $user) {
|
2020-04-10 15:19:56 +03:00
|
|
|
if ($user->getBackendClassName() === 'Database') {
|
2016-06-08 16:25:44 +03:00
|
|
|
$this->log(
|
|
|
|
'Password of user "%s" has been changed',
|
|
|
|
[
|
|
|
|
'user' => $user->getUID(),
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'user',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|