Merge branch 'master' into clean-settings-layout
commit
118f0d2b4d
@ -0,0 +1,2 @@
|
||||
*/Activity/* @nickvergessen
|
||||
*/Notifications/* @nickvergessen
|
||||
@ -1,34 +0,0 @@
|
||||
{
|
||||
"maxReviewers": 3,
|
||||
"numFilesToCheck": 5,
|
||||
"alwaysNotifyForPaths": [
|
||||
{
|
||||
"name": "nickvergessen",
|
||||
"files": [
|
||||
"lib/private/Activity/**",
|
||||
"lib/private/Notification/**",
|
||||
"lib/public/Activity/**",
|
||||
"lib/public/Notification/**"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Xenopathic",
|
||||
"files": [
|
||||
"apps/files_external/**"
|
||||
]
|
||||
}
|
||||
],
|
||||
"userBlacklist": [
|
||||
"DeepDiver1975",
|
||||
"nextcloud-bot",
|
||||
"owncloud-bot",
|
||||
"PVince81",
|
||||
"scrutinizer-auto-fixer",
|
||||
"th3fallen",
|
||||
"zander",
|
||||
"luckydonald",
|
||||
"jancborchardt"
|
||||
],
|
||||
"createReviewRequest": true,
|
||||
"createComment": false
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
* @author Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
* @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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\AdminAudit\Actions;
|
||||
|
||||
class AppManagement extends Action {
|
||||
|
||||
/**
|
||||
* @param string $appName
|
||||
*/
|
||||
public function enableApp($appName) {
|
||||
$this->log('App "%s" enabled',
|
||||
['app' => $appName],
|
||||
['app']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $appName
|
||||
* @param string[] $groups
|
||||
*/
|
||||
public function enableAppForGroups($appName, array $groups) {
|
||||
$this->log('App "%s" enabled for groups: %s',
|
||||
['app' => $appName, 'groups' => implode(', ', $groups)],
|
||||
['app', 'groups']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $appName
|
||||
*/
|
||||
public function disableApp($appName) {
|
||||
$this->log('App "%s" disabled',
|
||||
['app' => $appName],
|
||||
['app']
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
* @author Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
* @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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\AdminAudit\Actions;
|
||||
|
||||
|
||||
class Console extends Action {
|
||||
/**
|
||||
* @param $arguments
|
||||
*/
|
||||
public function runCommand($arguments) {
|
||||
if ($arguments[1] === '_completion') {
|
||||
// Don't log autocompletion
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove `./occ`
|
||||
array_shift($arguments);
|
||||
|
||||
$this->log('Console command executed: %s',
|
||||
['arguments' => implode(' ', $arguments)],
|
||||
['arguments']
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Joas Schilling <coding@schilljs.com>
|
||||
*
|
||||
* @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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\AdminAudit\AppInfo;
|
||||
|
||||
use OC\Files\Filesystem;
|
||||
use OC\Files\Node\File;
|
||||
use OC\Group\Manager;
|
||||
use OC\User\Session;
|
||||
use OCA\AdminAudit\Actions\AppManagement;
|
||||
use OCA\AdminAudit\Actions\Auth;
|
||||
use OCA\AdminAudit\Actions\Console;
|
||||
use OCA\AdminAudit\Actions\Files;
|
||||
use OCA\AdminAudit\Actions\GroupManagement;
|
||||
use OCA\AdminAudit\Actions\Sharing;
|
||||
use OCA\AdminAudit\Actions\Trashbin;
|
||||
use OCA\AdminAudit\Actions\UserManagement;
|
||||
use OCA\AdminAudit\Actions\Versions;
|
||||
use OCP\App\ManagerEvent;
|
||||
use OCP\AppFramework\App;
|
||||
use OCP\Console\ConsoleEvent;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\ILogger;
|
||||
use OCP\IPreview;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Util;
|
||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||
|
||||
class Application extends App {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct('admin_audit');
|
||||
}
|
||||
|
||||
public function register() {
|
||||
$this->registerHooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register hooks in order to log them
|
||||
*/
|
||||
protected function registerHooks() {
|
||||
$logger = $this->getContainer()->getServer()->getLogger();
|
||||
|
||||
$this->userManagementHooks($logger);
|
||||
$this->groupHooks($logger);
|
||||
$this->authHooks($logger);
|
||||
|
||||
$this->consoleHooks($logger);
|
||||
$this->appHooks($logger);
|
||||
|
||||
$this->sharingHooks($logger);
|
||||
|
||||
$this->fileHooks($logger);
|
||||
$this->trashbinHooks($logger);
|
||||
$this->versionsHooks($logger);
|
||||
}
|
||||
|
||||
protected function userManagementHooks(ILogger $logger) {
|
||||
$userActions = new UserManagement($logger);
|
||||
|
||||
Util::connectHook('OC_User', 'post_createUser', $userActions, 'create');
|
||||
Util::connectHook('OC_User', 'post_deleteUser', $userActions, 'delete');
|
||||
Util::connectHook('OC_User', 'changeUser', $userActions, 'change');
|
||||
|
||||
/** @var IUserSession|Session $userSession */
|
||||
$userSession = $this->getContainer()->getServer()->getUserSession();
|
||||
$userSession->listen('\OC\User', 'postSetPassword', [$userActions, 'setPassword']);
|
||||
}
|
||||
|
||||
protected function groupHooks(ILogger $logger) {
|
||||
$groupActions = new GroupManagement($logger);
|
||||
|
||||
/** @var IGroupManager|Manager $groupManager */
|
||||
$groupManager = $this->getContainer()->getServer()->getGroupManager();
|
||||
$groupManager->listen('\OC\Group', 'postRemoveUser', [$groupActions, 'removeUser']);
|
||||
$groupManager->listen('\OC\Group', 'postAddUser', [$groupActions, 'addUser']);
|
||||
$groupManager->listen('\OC\Group', 'postDelete', [$groupActions, 'deleteGroup']);
|
||||
$groupManager->listen('\OC\Group', 'postCreate', [$groupActions, 'createGroup']);
|
||||
}
|
||||
|
||||
protected function sharingHooks(ILogger $logger) {
|
||||
$shareActions = new Sharing($logger);
|
||||
|
||||
Util::connectHook('OCP\Share', 'post_shared', $shareActions, 'shared');
|
||||
Util::connectHook('OCP\Share', 'post_unshare', $shareActions, 'unshare');
|
||||
Util::connectHook('OCP\Share', 'post_update_permissions', $shareActions, 'updatePermissions');
|
||||
Util::connectHook('OCP\Share', 'post_update_password', $shareActions, 'updatePassword');
|
||||
Util::connectHook('OCP\Share', 'post_set_expiration_date', $shareActions, 'updateExpirationDate');
|
||||
Util::connectHook('OCP\Share', 'share_link_access', $shareActions, 'shareAccessed');
|
||||
}
|
||||
|
||||
protected function authHooks(ILogger $logger) {
|
||||
$authActions = new Auth($logger);
|
||||
|
||||
Util::connectHook('OC_User', 'pre_login', $authActions, 'loginAttempt');
|
||||
Util::connectHook('OC_User', 'post_login', $authActions, 'loginSuccessful');
|
||||
Util::connectHook('OC_User', 'logout', $authActions, 'logout');
|
||||
}
|
||||
|
||||
protected function appHooks(ILogger $logger) {
|
||||
|
||||
$eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
|
||||
$eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE, function(ManagerEvent $event) use ($logger) {
|
||||
$appActions = new AppManagement($logger);
|
||||
$appActions->enableApp($event->getAppID());
|
||||
});
|
||||
$eventDispatcher->addListener(ManagerEvent::EVENT_APP_ENABLE_FOR_GROUPS, function(ManagerEvent $event) use ($logger) {
|
||||
$appActions = new AppManagement($logger);
|
||||
$appActions->enableAppForGroups($event->getAppID(), $event->getGroups());
|
||||
});
|
||||
$eventDispatcher->addListener(ManagerEvent::EVENT_APP_DISABLE, function(ManagerEvent $event) use ($logger) {
|
||||
$appActions = new AppManagement($logger);
|
||||
$appActions->disableApp($event->getAppID());
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected function consoleHooks(ILogger $logger) {
|
||||
$eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
|
||||
$eventDispatcher->addListener(ConsoleEvent::EVENT_RUN, function(ConsoleEvent $event) use ($logger) {
|
||||
$appActions = new Console($logger);
|
||||
$appActions->runCommand($event->getArguments());
|
||||
});
|
||||
}
|
||||
|
||||
protected function fileHooks(ILogger $logger) {
|
||||
$fileActions = new Files($logger);
|
||||
$eventDispatcher = $this->getContainer()->getServer()->getEventDispatcher();
|
||||
$eventDispatcher->addListener(
|
||||
IPreview::EVENT,
|
||||
function(GenericEvent $event) use ($fileActions) {
|
||||
/** @var File $file */
|
||||
$file = $event->getSubject();
|
||||
$fileActions->preview([
|
||||
'path' => substr($file->getInternalPath(), 5),
|
||||
'width' => $event->getArguments()['width'],
|
||||
'height' => $event->getArguments()['height'],
|
||||
'crop' => $event->getArguments()['crop'],
|
||||
'mode' => $event->getArguments()['mode']
|
||||
]);
|
||||
}
|
||||
);
|
||||
|
||||
Util::connectHook(
|
||||
Filesystem::CLASSNAME,
|
||||
Filesystem::signal_post_rename,
|
||||
$fileActions,
|
||||
'rename'
|
||||
);
|
||||
Util::connectHook(
|
||||
Filesystem::CLASSNAME,
|
||||
Filesystem::signal_post_create,
|
||||
$fileActions,
|
||||
'create'
|
||||
);
|
||||
Util::connectHook(
|
||||
Filesystem::CLASSNAME,
|
||||
Filesystem::signal_post_copy,
|
||||
$fileActions,
|
||||
'copy'
|
||||
);
|
||||
Util::connectHook(
|
||||
Filesystem::CLASSNAME,
|
||||
Filesystem::signal_post_write,
|
||||
$fileActions,
|
||||
'write'
|
||||
);
|
||||
Util::connectHook(
|
||||
Filesystem::CLASSNAME,
|
||||
Filesystem::signal_post_update,
|
||||
$fileActions,
|
||||
'update'
|
||||
);
|
||||
Util::connectHook(
|
||||
Filesystem::CLASSNAME,
|
||||
Filesystem::signal_read,
|
||||
$fileActions,
|
||||
'read'
|
||||
);
|
||||
Util::connectHook(
|
||||
Filesystem::CLASSNAME,
|
||||
Filesystem::signal_delete,
|
||||
$fileActions,
|
||||
'delete'
|
||||
);
|
||||
}
|
||||
|
||||
protected function versionsHooks(ILogger $logger) {
|
||||
$versionsActions = new Versions($logger);
|
||||
Util::connectHook('\OCP\Versions', 'rollback', $versionsActions, 'rollback');
|
||||
Util::connectHook('\OCP\Versions', 'delete',$versionsActions, 'delete');
|
||||
}
|
||||
|
||||
protected function trashbinHooks(ILogger $logger) {
|
||||
$trashActions = new Trashbin($logger);
|
||||
Util::connectHook('\OCP\Trashbin', 'preDelete', $trashActions, 'delete');
|
||||
Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', $trashActions, 'restore');
|
||||
}
|
||||
}
|
||||
@ -1,209 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2016 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
* @copyright Copyright (c) 2017 Lukas Reschke <lukas@statuscode.ch>
|
||||
*
|
||||
* @author Bjoern Schiessle <bjoern@schiessle.org>
|
||||
* @author Lukas Reschke <lukas@statuscode.ch>
|
||||
* @author Roger Szabo <roger.szabo@web.de>
|
||||
*
|
||||
* @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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Admin_Audit;
|
||||
|
||||
use OC\Files\Filesystem;
|
||||
use OC\Files\Node\File;
|
||||
use OCA\Admin_Audit\Actions\Auth;
|
||||
use OCA\Admin_Audit\Actions\Files;
|
||||
use OCA\Admin_Audit\Actions\GroupManagement;
|
||||
use OCA\Admin_Audit\Actions\Sharing;
|
||||
use OCA\Admin_Audit\Actions\Trashbin;
|
||||
use OCA\Admin_Audit\Actions\UserManagement;
|
||||
use OCA\Admin_Audit\Actions\Versions;
|
||||
use OCP\IGroupManager;
|
||||
use OCP\ILogger;
|
||||
use OCP\IPreview;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Util;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\GenericEvent;
|
||||
|
||||
class AuditLogger {
|
||||
/** @var ILogger */
|
||||
private $logger;
|
||||
/** @var IUserSession */
|
||||
private $userSession;
|
||||
/** @var IGroupManager */
|
||||
private $groupManager;
|
||||
|
||||
/**
|
||||
* AuditLogger constructor.
|
||||
*
|
||||
* @param ILogger $logger
|
||||
* @param IUserSession $userSession
|
||||
* @param IGroupManager $groupManager
|
||||
* @param EventDispatcherInterface $eventDispatcher
|
||||
*/
|
||||
public function __construct(ILogger $logger,
|
||||
IUserSession $userSession,
|
||||
IGroupManager $groupManager,
|
||||
EventDispatcherInterface $eventDispatcher) {
|
||||
$this->logger = $logger;
|
||||
$this->userSession = $userSession;
|
||||
$this->groupManager = $groupManager;
|
||||
$this->eventDispatcher = $eventDispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register hooks in order to log them
|
||||
*/
|
||||
public function registerHooks() {
|
||||
$this->userManagementHooks();
|
||||
$this->groupHooks();
|
||||
$this->sharingHooks();
|
||||
$this->authHooks();
|
||||
$this->fileHooks();
|
||||
$this->trashbinHooks();
|
||||
$this->versionsHooks();
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to user management hooks
|
||||
*/
|
||||
private function userManagementHooks() {
|
||||
$userActions = new UserManagement($this->logger);
|
||||
|
||||
Util::connectHook('OC_User', 'post_createUser', $userActions, 'create');
|
||||
Util::connectHook('OC_User', 'post_deleteUser', $userActions, 'delete');
|
||||
Util::connectHook('OC_User', 'changeUser', $userActions, 'change');
|
||||
$this->userSession->listen('\OC\User', 'postSetPassword', [$userActions, 'setPassword']);
|
||||
}
|
||||
|
||||
private function groupHooks() {
|
||||
$groupActions = new GroupManagement($this->logger);
|
||||
$this->groupManager->listen('\OC\Group', 'postRemoveUser', [$groupActions, 'removeUser']);
|
||||
$this->groupManager->listen('\OC\Group', 'postAddUser', [$groupActions, 'addUser']);
|
||||
$this->groupManager->listen('\OC\Group', 'postDelete', [$groupActions, 'deleteGroup']);
|
||||
$this->groupManager->listen('\OC\Group', 'postCreate', [$groupActions, 'createGroup']);
|
||||
}
|
||||
|
||||
/**
|
||||
* connect to sharing events
|
||||
*/
|
||||
private function sharingHooks() {
|
||||
$shareActions = new Sharing($this->logger);
|
||||
|
||||
Util::connectHook('OCP\Share', 'post_shared', $shareActions, 'shared');
|
||||
Util::connectHook('OCP\Share', 'post_unshare', $shareActions, 'unshare');
|
||||
Util::connectHook('OCP\Share', 'post_update_permissions', $shareActions, 'updatePermissions');
|
||||
Util::connectHook('OCP\Share', 'post_update_password', $shareActions, 'updatePassword');
|
||||
Util::connectHook('OCP\Share', 'post_set_expiration_date', $shareActions, 'updateExpirationDate');
|
||||
Util::connectHook('OCP\Share', 'share_link_access', $shareActions, 'shareAccessed');
|
||||
}
|
||||
|
||||
/**
|
||||
* connect to authentication event and related actions
|
||||
*/
|
||||
private function authHooks() {
|
||||
$authActions = new Auth($this->logger);
|
||||
|
||||
Util::connectHook('OC_User', 'pre_login', $authActions, 'loginAttempt');
|
||||
Util::connectHook('OC_User', 'post_login', $authActions, 'loginSuccessful');
|
||||
Util::connectHook('OC_User', 'logout', $authActions, 'logout');
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to file hooks
|
||||
*/
|
||||
private function fileHooks() {
|
||||
$fileActions = new Files($this->logger);
|
||||
$this->eventDispatcher->addListener(
|
||||
IPreview::EVENT,
|
||||
function(GenericEvent $event) use ($fileActions) {
|
||||
/** @var File $file */
|
||||
$file = $event->getSubject();
|
||||
$fileActions->preview([
|
||||
'path' => substr($file->getInternalPath(), 5),
|
||||
'width' => $event->getArguments()['width'],
|
||||
'height' => $event->getArguments()['height'],
|
||||
'crop' => $event->getArguments()['crop'],
|
||||
'mode' => $event->getArguments()['mode']
|
||||
]);
|
||||
}
|
||||
);
|
||||
|
||||
Util::connectHook(
|
||||
Filesystem::CLASSNAME,
|
||||
Filesystem::signal_post_rename,
|
||||
$fileActions,
|
||||
'rename'
|
||||
);
|
||||
Util::connectHook(
|
||||
Filesystem::CLASSNAME,
|
||||
Filesystem::signal_post_create,
|
||||
$fileActions,
|
||||
'create'
|
||||
);
|
||||
Util::connectHook(
|
||||
Filesystem::CLASSNAME,
|
||||
Filesystem::signal_post_copy,
|
||||
$fileActions,
|
||||
'copy'
|
||||
);
|
||||
Util::connectHook(
|
||||
Filesystem::CLASSNAME,
|
||||
Filesystem::signal_post_write,
|
||||
$fileActions,
|
||||
'write'
|
||||
);
|
||||
Util::connectHook(
|
||||
Filesystem::CLASSNAME,
|
||||
Filesystem::signal_post_update,
|
||||
$fileActions,
|
||||
'update'
|
||||
);
|
||||
Util::connectHook(
|
||||
Filesystem::CLASSNAME,
|
||||
Filesystem::signal_read,
|
||||
$fileActions,
|
||||
'read'
|
||||
);
|
||||
Util::connectHook(
|
||||
Filesystem::CLASSNAME,
|
||||
Filesystem::signal_delete,
|
||||
$fileActions,
|
||||
'delete'
|
||||
);
|
||||
}
|
||||
|
||||
public function versionsHooks() {
|
||||
$versionsActions = new Versions($this->logger);
|
||||
Util::connectHook('\OCP\Versions', 'rollback', $versionsActions, 'rollback');
|
||||
Util::connectHook('\OCP\Versions', 'delete',$versionsActions, 'delete');
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to trash bin hooks
|
||||
*/
|
||||
private function trashbinHooks() {
|
||||
$trashActions = new Trashbin($this->logger);
|
||||
Util::connectHook('\OCP\Trashbin', 'preDelete', $trashActions, 'delete');
|
||||
Util::connectHook('\OCA\Files_Trashbin\Trashbin', 'post_restore', $trashActions, 'restore');
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="32" width="32" viewBox="0 0 32 32"><path fill="#000" d="M16 3C7.163 3 0 7.925 0 14s7.163 11 16 11c.5 0 .98-.032 1.47-.063L26 32v-9.406c3.658-2.017 6-5.12 6-8.595 0-6.076-7.164-11-16-11z"/></svg>
|
||||
|
After Width: | Height: | Size: 243 B |
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
||||
*
|
||||
* @author Joas Schilling <coding@schilljs.com>
|
||||
* @author Robin Appelman <robin@icewind.nl>
|
||||
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
||||
*
|
||||
* @license AGPL-3.0
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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, version 3,
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\DAV\Tests\unit\Connector\Sabre\RequestTest;
|
||||
|
||||
use OC\Files\View;
|
||||
use Test\Traits\EncryptionTrait;
|
||||
|
||||
/**
|
||||
* Class EncryptionMasterKeyUploadTest
|
||||
*
|
||||
* @group DB
|
||||
*
|
||||
* @package OCA\DAV\Tests\Unit\Connector\Sabre\RequestTest
|
||||
*/
|
||||
class EncryptionMasterKeyUploadTest extends UploadTest {
|
||||
use EncryptionTrait;
|
||||
|
||||
protected function setupUser($name, $password) {
|
||||
$this->createUser($name, $password);
|
||||
$tmpFolder = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
$this->registerMount($name, '\OC\Files\Storage\Local', '/' . $name, ['datadir' => $tmpFolder]);
|
||||
// we use the master key
|
||||
\OC::$server->getConfig()->setAppValue('encryption', 'useMasterKey', '1');
|
||||
$this->setupForUser($name, $password);
|
||||
$this->loginWithEncryption($name);
|
||||
return new View('/' . $name . '/files');
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
*
|
||||
* @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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace OCA\Encryption\Command;
|
||||
|
||||
|
||||
use OCA\Encryption\Util;
|
||||
use OCP\IConfig;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Helper\QuestionHelper;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Question\ConfirmationQuestion;
|
||||
|
||||
class DisableMasterKey extends Command {
|
||||
|
||||
/** @var Util */
|
||||
protected $util;
|
||||
|
||||
/** @var IConfig */
|
||||
protected $config;
|
||||
|
||||
/** @var QuestionHelper */
|
||||
protected $questionHelper;
|
||||
|
||||
/**
|
||||
* @param Util $util
|
||||
* @param IConfig $config
|
||||
* @param QuestionHelper $questionHelper
|
||||
*/
|
||||
public function __construct(Util $util,
|
||||
IConfig $config,
|
||||
QuestionHelper $questionHelper) {
|
||||
|
||||
$this->util = $util;
|
||||
$this->config = $config;
|
||||
$this->questionHelper = $questionHelper;
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure() {
|
||||
$this
|
||||
->setName('encryption:disable-master-key')
|
||||
->setDescription('Disable the master key and use per-user keys instead. Only available for fresh installations with no existing encrypted data! There is no way to enable it again.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
|
||||
$isMasterKeyEnabled = $this->util->isMasterKeyEnabled();
|
||||
|
||||
if(!$isMasterKeyEnabled) {
|
||||
$output->writeln('Master key already disabled');
|
||||
} else {
|
||||
$question = new ConfirmationQuestion(
|
||||
'Warning: Only perform this operation for a fresh installations with no existing encrypted data! '
|
||||
. 'There is no way to enable the master key again. '
|
||||
. 'We strongly recommend to keep the master key, it provides significant performance improvements '
|
||||
. 'and is easier to handle for both, users and administrators. '
|
||||
. 'Do you really want to switch to per-user keys? (y/n) ', false);
|
||||
if ($this->questionHelper->ask($input, $output, $question)) {
|
||||
$this->config->setAppValue('encryption', 'useMasterKey', '0');
|
||||
$output->writeln('Master key successfully disabled.');
|
||||
} else {
|
||||
$output->writeln('aborted.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Bjoern Schiessle <bjoern@schiessle.org>
|
||||
*
|
||||
* @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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace OCA\Encryption\Migration;
|
||||
|
||||
|
||||
use OCP\IConfig;
|
||||
use OCP\Migration\IOutput;
|
||||
use OCP\Migration\IRepairStep;
|
||||
|
||||
/**
|
||||
* Class SetPasswordColumn
|
||||
*
|
||||
* @package OCA\Files_Sharing\Migration
|
||||
*/
|
||||
class SetMasterKeyStatus implements IRepairStep {
|
||||
|
||||
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
|
||||
|
||||
public function __construct(IConfig $config) {
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the step's name
|
||||
*
|
||||
* @return string
|
||||
* @since 9.1.0
|
||||
*/
|
||||
public function getName() {
|
||||
return 'Write default encryption module configuration to the database';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param IOutput $output
|
||||
*/
|
||||
public function run(IOutput $output) {
|
||||
if (!$this->shouldRun()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// if no config for the master key is set we set it explicitly to '0' in
|
||||
// order not to break old installations because the default changed to '1'.
|
||||
$configAlreadySet = $this->config->getAppValue('encryption', 'useMasterKey', false);
|
||||
if ($configAlreadySet === false) {
|
||||
$this->config->setAppValue('encryption', 'useMasterKey', '0');
|
||||
}
|
||||
}
|
||||
|
||||
protected function shouldRun() {
|
||||
$appVersion = $this->config->getAppValue('encryption', 'installed_version', '0.0.0');
|
||||
return version_compare($appVersion, '2.0.0', '<');
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2017 Arthur Schiwon <blizzz@arthur-schiwon.de>
|
||||
*
|
||||
* @author Arthur Schiwon <blizzz@arthur-schiwon.de>
|
||||
*
|
||||
* @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
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OCA\Encryption\Settings;
|
||||
|
||||
|
||||
use OCA\Encryption\Session;
|
||||
use OCA\Encryption\Util;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\IConfig;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Settings\ISettings;
|
||||
|
||||
class Personal implements ISettings {
|
||||
|
||||
/** @var IConfig */
|
||||
private $config;
|
||||
/** @var Session */
|
||||
private $session;
|
||||
/** @var Util */
|
||||
private $util;
|
||||
/** @var IUserSession */
|
||||
private $userSession;
|
||||
|
||||
public function __construct(IConfig $config, Session $session, Util $util, IUserSession $userSession) {
|
||||
$this->config = $config;
|
||||
$this->session = $session;
|
||||
$this->util = $util;
|
||||
$this->userSession = $userSession;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TemplateResponse returns the instance with all parameters set, ready to be rendered
|
||||
* @since 9.1
|
||||
*/
|
||||
public function getForm() {
|
||||
$recoveryAdminEnabled = $this->config->getAppValue('encryption', 'recoveryAdminEnabled');
|
||||
$privateKeySet = $this->session->isPrivateKeySet();
|
||||
|
||||
if (!$recoveryAdminEnabled && $privateKeySet) {
|
||||
return new TemplateResponse('settings', 'settings/empty', [], '');
|
||||
}
|
||||
|
||||
$userId = $this->userSession->getUser()->getUID();
|
||||
$recoveryEnabledForUser = $this->util->isRecoveryEnabledForUser($userId);
|
||||
|
||||
$parameters = [
|
||||
'recoveryEnabled' => $recoveryAdminEnabled,
|
||||
'recoveryEnabledForUser' => $recoveryEnabledForUser,
|
||||
'privateKeySet' => $privateKeySet,
|
||||
'initialized' => $this->session->getStatus(),
|
||||
];
|
||||
return new TemplateResponse('encryption', 'settings-personal', $parameters, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the section ID, e.g. 'sharing'
|
||||
* @since 9.1
|
||||
*/
|
||||
public function getSection() {
|
||||
return 'security';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int whether the form should be rather on the top or bottom of
|
||||
* the admin section. The forms are arranged in ascending order of the
|
||||
* priority values. It is required to return a value between 0 and 100.
|
||||
*
|
||||
* E.g.: 70
|
||||
* @since 9.1
|
||||
*/
|
||||
public function getPriority() {
|
||||
return 80;
|
||||
}
|
||||
}
|
||||
@ -1,76 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
||||
*
|
||||
* @author Björn Schießle <bjoern@schiessle.org>
|
||||
* @author Clark Tomlinson <fallen013@gmail.com>
|
||||
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
||||
*
|
||||
* @license AGPL-3.0
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* 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, version 3,
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*/
|
||||
|
||||
$session = new \OCA\Encryption\Session(\OC::$server->getSession());
|
||||
$userSession = \OC::$server->getUserSession();
|
||||
|
||||
$template = new OCP\Template('encryption', 'settings-personal');
|
||||
$crypt = new \OCA\Encryption\Crypto\Crypt(
|
||||
\OC::$server->getLogger(),
|
||||
$userSession,
|
||||
\OC::$server->getConfig(),
|
||||
\OC::$server->getL10N('encryption'));
|
||||
|
||||
$util = new \OCA\Encryption\Util(
|
||||
new \OC\Files\View(),
|
||||
$crypt,
|
||||
\OC::$server->getLogger(),
|
||||
$userSession,
|
||||
\OC::$server->getConfig(),
|
||||
\OC::$server->getUserManager());
|
||||
|
||||
$keyManager = new \OCA\Encryption\KeyManager(
|
||||
\OC::$server->getEncryptionKeyStorage(),
|
||||
$crypt,
|
||||
\OC::$server->getConfig(),
|
||||
$userSession,
|
||||
$session,
|
||||
\OC::$server->getLogger(), $util);
|
||||
|
||||
$user = $userSession->getUser()->getUID();
|
||||
|
||||
$view = new \OC\Files\View('/');
|
||||
|
||||
|
||||
|
||||
$privateKeySet = $session->isPrivateKeySet();
|
||||
// did we tried to initialize the keys for this session?
|
||||
$initialized = $session->getStatus();
|
||||
|
||||
$recoveryAdminEnabled = \OC::$server->getConfig()->getAppValue('encryption', 'recoveryAdminEnabled');
|
||||
$recoveryEnabledForUser = $util->isRecoveryEnabledForUser($user);
|
||||
|
||||
$result = false;
|
||||
|
||||
if ($recoveryAdminEnabled || !$privateKeySet) {
|
||||
$template->assign('recoveryEnabled', $recoveryAdminEnabled);
|
||||
$template->assign('recoveryEnabledForUser', $recoveryEnabledForUser);
|
||||
$template->assign('privateKeySet', $privateKeySet);
|
||||
$template->assign('initialized', $initialized);
|
||||
|
||||
$result = $template->fetchPage();
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue