Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2017-05-19 01:50:44 +0300
committerGitHub <noreply@github.com>2017-05-19 01:50:44 +0300
commit7976927628fba974570753759b9aaebb1faee413 (patch)
tree0c0b64e674795f21008c10c24d40e56953a2643f
parent8c624bdef9f3d7c2304ba4a3fba9dbbb23c65f3e (diff)
parent19a1e01d6cc08e486bb5afe83f25b2c28852603d (diff)
Merge pull request #4894 from nextcloud/generic-security-activities
Change 2FA activities to more generic security activities
-rw-r--r--apps/twofactor_backupcodes/appinfo/info.xml7
-rw-r--r--apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php2
-rw-r--r--apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php2
-rw-r--r--lib/composer/composer/autoload_classmap.php3
-rw-r--r--lib/composer/composer/autoload_static.php3
-rw-r--r--lib/private/Authentication/TwoFactorAuth/Manager.php11
-rw-r--r--settings/Activity/SecurityFilter.php (renamed from apps/twofactor_backupcodes/lib/Activity/GenericFilter.php)10
-rw-r--r--settings/Activity/SecurityProvider.php (renamed from apps/twofactor_backupcodes/lib/Activity/GenericProvider.php)6
-rw-r--r--settings/Activity/SecuritySetting.php (renamed from apps/twofactor_backupcodes/lib/Activity/GenericSetting.php)8
-rw-r--r--settings/Application.php6
-rw-r--r--tests/Settings/Activity/SecurityFilterTest.php (renamed from apps/twofactor_backupcodes/tests/Unit/Activity/GenericFilterTest.php)16
-rw-r--r--tests/Settings/Activity/SecurityProviderTest.php (renamed from apps/twofactor_backupcodes/tests/Unit/Activity/GenericProviderTest.php)14
-rw-r--r--tests/Settings/Activity/SecuritySettingTest.php (renamed from apps/twofactor_backupcodes/tests/Unit/Activity/SettingTest.php)18
-rw-r--r--tests/lib/Authentication/TwoFactorAuth/ManagerTest.php8
14 files changed, 60 insertions, 54 deletions
diff --git a/apps/twofactor_backupcodes/appinfo/info.xml b/apps/twofactor_backupcodes/appinfo/info.xml
index e5e96eddcf9..77ecbd8e1a2 100644
--- a/apps/twofactor_backupcodes/appinfo/info.xml
+++ b/apps/twofactor_backupcodes/appinfo/info.xml
@@ -18,14 +18,7 @@
</dependencies>
<activity>
- <filters>
- <filter>OCA\TwoFactorBackupCodes\Activity\GenericFilter</filter>
- </filters>
- <settings>
- <setting>OCA\TwoFactorBackupCodes\Activity\GenericSetting</setting>
- </settings>
<providers>
- <provider>OCA\TwoFactorBackupCodes\Activity\GenericProvider</provider>
<provider>OCA\TwoFactorBackupCodes\Activity\Provider</provider>
</providers>
</activity>
diff --git a/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php b/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php
index 1cf62d18801..84bf54d3379 100644
--- a/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php
+++ b/apps/twofactor_backupcodes/lib/Service/BackupCodeStorage.php
@@ -103,7 +103,7 @@ class BackupCodeStorage {
private function publishEvent(IUser $user, $event) {
$activity = $this->activityManager->generateEvent();
$activity->setApp('twofactor_backupcodes')
- ->setType('twofactor')
+ ->setType('security')
->setAuthor($user->getUID())
->setAffectedUser($user->getUID())
->setSubject($event);
diff --git a/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php b/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php
index 109db7f688c..d2387bd6ccd 100644
--- a/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php
+++ b/apps/twofactor_backupcodes/tests/Unit/Service/BackupCodeStorageTest.php
@@ -98,7 +98,7 @@ class BackupCodeStorageTest extends TestCase {
->will($this->returnSelf());
$event->expects($this->once())
->method('setType')
- ->with('twofactor')
+ ->with('security')
->will($this->returnSelf());
$event->expects($this->once())
->method('setAuthor')
diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php
index 8e65ca365e4..326c0856e50 100644
--- a/lib/composer/composer/autoload_classmap.php
+++ b/lib/composer/composer/autoload_classmap.php
@@ -786,6 +786,9 @@ return array(
'OC\\Session\\Memory' => $baseDir . '/lib/private/Session/Memory.php',
'OC\\Session\\Session' => $baseDir . '/lib/private/Session/Session.php',
'OC\\Settings\\Activity\\Provider' => $baseDir . '/settings/Activity/Provider.php',
+ 'OC\\Settings\\Activity\\SecurityFilter' => $baseDir . '/settings/Activity/SecurityFilter.php',
+ 'OC\\Settings\\Activity\\SecurityProvider' => $baseDir . '/settings/Activity/SecurityProvider.php',
+ 'OC\\Settings\\Activity\\SecuritySetting' => $baseDir . '/settings/Activity/SecuritySetting.php',
'OC\\Settings\\Activity\\Setting' => $baseDir . '/settings/Activity/Setting.php',
'OC\\Settings\\Admin\\Additional' => $baseDir . '/lib/private/Settings/Admin/Additional.php',
'OC\\Settings\\Admin\\Encryption' => $baseDir . '/lib/private/Settings/Admin/Encryption.php',
diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php
index b9a1545e6a3..c1ef42c1273 100644
--- a/lib/composer/composer/autoload_static.php
+++ b/lib/composer/composer/autoload_static.php
@@ -816,6 +816,9 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c
'OC\\Session\\Memory' => __DIR__ . '/../../..' . '/lib/private/Session/Memory.php',
'OC\\Session\\Session' => __DIR__ . '/../../..' . '/lib/private/Session/Session.php',
'OC\\Settings\\Activity\\Provider' => __DIR__ . '/../../..' . '/settings/Activity/Provider.php',
+ 'OC\\Settings\\Activity\\SecurityFilter' => __DIR__ . '/../../..' . '/settings/Activity/SecurityFilter.php',
+ 'OC\\Settings\\Activity\\SecurityProvider' => __DIR__ . '/../../..' . '/settings/Activity/SecurityProvider.php',
+ 'OC\\Settings\\Activity\\SecuritySetting' => __DIR__ . '/../../..' . '/settings/Activity/SecuritySetting.php',
'OC\\Settings\\Activity\\Setting' => __DIR__ . '/../../..' . '/settings/Activity/Setting.php',
'OC\\Settings\\Admin\\Additional' => __DIR__ . '/../../..' . '/lib/private/Settings/Admin/Additional.php',
'OC\\Settings\\Admin\\Encryption' => __DIR__ . '/../../..' . '/lib/private/Settings/Admin/Encryption.php',
diff --git a/lib/private/Authentication/TwoFactorAuth/Manager.php b/lib/private/Authentication/TwoFactorAuth/Manager.php
index 1d0deada696..06aa0224ae0 100644
--- a/lib/private/Authentication/TwoFactorAuth/Manager.php
+++ b/lib/private/Authentication/TwoFactorAuth/Manager.php
@@ -23,6 +23,7 @@
namespace OC\Authentication\TwoFactorAuth;
+use BadMethodCallException;
use Exception;
use OC;
use OC\App\AppManager;
@@ -218,16 +219,16 @@ class Manager {
*/
private function publishEvent(IUser $user, $event, array $params) {
$activity = $this->activityManager->generateEvent();
- $activity->setApp('twofactor_generic')
- ->setType('twofactor')
+ $activity->setApp('core')
+ ->setType('security')
->setAuthor($user->getUID())
->setAffectedUser($user->getUID())
->setSubject($event, $params);
try {
$this->activityManager->publish($activity);
- } catch (Exception $e) {
- $this->logger->warning('could not publish backup code creation activity', ['app' => 'twofactor_backupcodes']);
- $this->logger->logException($e, ['app' => 'twofactor_backupcodes']);
+ } catch (BadMethodCallException $e) {
+ $this->logger->warning('could not publish backup code creation activity', ['app' => 'core']);
+ $this->logger->logException($e, ['app' => 'core']);
}
}
diff --git a/apps/twofactor_backupcodes/lib/Activity/GenericFilter.php b/settings/Activity/SecurityFilter.php
index 27c0274b600..6bf36a9e488 100644
--- a/apps/twofactor_backupcodes/lib/Activity/GenericFilter.php
+++ b/settings/Activity/SecurityFilter.php
@@ -20,13 +20,13 @@
*
*/
-namespace OCA\TwoFactorBackupCodes\Activity;
+namespace OC\Settings\Activity;
use OCP\Activity\IFilter;
use OCP\IL10N;
use OCP\IURLGenerator;
-class GenericFilter implements IFilter {
+class SecurityFilter implements IFilter {
/** @var IURLGenerator */
private $urlGenerator;
@@ -44,7 +44,7 @@ class GenericFilter implements IFilter {
}
public function filterTypes(array $types) {
- return array_intersect(['twofactor'], $types);
+ return array_intersect(['security'], $types);
}
public function getIcon() {
@@ -52,11 +52,11 @@ class GenericFilter implements IFilter {
}
public function getIdentifier() {
- return 'twofactor';
+ return 'security';
}
public function getName() {
- return $this->l10n->t('Two-factor authentication');
+ return $this->l10n->t('Security');
}
public function getPriority() {
diff --git a/apps/twofactor_backupcodes/lib/Activity/GenericProvider.php b/settings/Activity/SecurityProvider.php
index ffdd47708d5..74747f684da 100644
--- a/apps/twofactor_backupcodes/lib/Activity/GenericProvider.php
+++ b/settings/Activity/SecurityProvider.php
@@ -20,7 +20,7 @@
*
*/
-namespace OCA\TwoFactorBackupCodes\Activity;
+namespace OC\Settings\Activity;
use InvalidArgumentException;
use OCP\Activity\IEvent;
@@ -29,7 +29,7 @@ use OCP\ILogger;
use OCP\IURLGenerator;
use OCP\L10N\IFactory as L10nFactory;
-class GenericProvider implements IProvider {
+class SecurityProvider implements IProvider {
/** @var L10nFactory */
private $l10n;
@@ -47,7 +47,7 @@ class GenericProvider implements IProvider {
}
public function parse($language, IEvent $event, IEvent $previousEvent = null) {
- if ($event->getType() !== 'twofactor') {
+ if ($event->getType() !== 'security') {
throw new InvalidArgumentException();
}
diff --git a/apps/twofactor_backupcodes/lib/Activity/GenericSetting.php b/settings/Activity/SecuritySetting.php
index abd1c60f1d5..fe1b0dd8f57 100644
--- a/apps/twofactor_backupcodes/lib/Activity/GenericSetting.php
+++ b/settings/Activity/SecuritySetting.php
@@ -20,12 +20,12 @@
*
*/
-namespace OCA\TwoFactorBackupCodes\Activity;
+namespace OC\Settings\Activity;
use OCP\Activity\ISetting;
use OCP\IL10N;
-class GenericSetting implements ISetting {
+class SecuritySetting implements ISetting {
/** @var IL10N */
private $l10n;
@@ -43,11 +43,11 @@ class GenericSetting implements ISetting {
}
public function getIdentifier() {
- return 'twofactor';
+ return 'security';
}
public function getName() {
- return $this->l10n->t('Two-factor authentication');
+ return $this->l10n->t('Security');
}
public function getPriority() {
diff --git a/settings/Application.php b/settings/Application.php
index 0ca2d28dfe6..f79453e3d01 100644
--- a/settings/Application.php
+++ b/settings/Application.php
@@ -34,6 +34,9 @@ use OC\AppFramework\Utility\TimeFactory;
use OC\Authentication\Token\IProvider;
use OC\Server;
use OC\Settings\Activity\Provider;
+use OC\Settings\Activity\SecurityFilter;
+use OC\Settings\Activity\SecurityProvider;
+use OC\Settings\Activity\SecuritySetting;
use OC\Settings\Activity\Setting;
use OC\Settings\Mailer\NewUserMailHelper;
use OC\Settings\Middleware\SubadminMiddleware;
@@ -114,6 +117,9 @@ class Application extends App {
$activityManager = $this->getContainer()->getServer()->getActivityManager();
$activityManager->registerSetting(Setting::class); // FIXME move to info.xml
$activityManager->registerProvider(Provider::class); // FIXME move to info.xml
+ $activityManager->registerFilter(SecurityFilter::class); // FIXME move to info.xml
+ $activityManager->registerSetting(SecuritySetting::class); // FIXME move to info.xml
+ $activityManager->registerProvider(SecurityProvider::class); // FIXME move to info.xml
Util::connectHook('OC_User', 'post_setPassword', $this, 'onChangePassword');
Util::connectHook('OC_User', 'changeUser', $this, 'onChangeInfo');
diff --git a/apps/twofactor_backupcodes/tests/Unit/Activity/GenericFilterTest.php b/tests/Settings/Activity/SecurityFilterTest.php
index ca24c0be647..44345b83fa5 100644
--- a/apps/twofactor_backupcodes/tests/Unit/Activity/GenericFilterTest.php
+++ b/tests/Settings/Activity/SecurityFilterTest.php
@@ -20,19 +20,19 @@
*
*/
-namespace OCA\TwoFactorBackupCodes\Test\Unit\Activity;
+namespace Tests\Settings\Activity;
-use OCA\TwoFactorBackupCodes\Activity\GenericFilter;
+use OC\Settings\Activity\SecurityFilter;
use OCP\IL10N;
use OCP\IURLGenerator;
use Test\TestCase;
-class GenericFilterTest extends TestCase {
+class SecurityFilterTest extends TestCase {
private $urlGenerator;
private $l10n;
- /** @var GenericFilter */
+ /** @var SecurityFilter */
private $filter;
protected function setUp() {
@@ -41,7 +41,7 @@ class GenericFilterTest extends TestCase {
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->l10n = $this->createMock(IL10N::class);
- $this->filter = new GenericFilter($this->urlGenerator, $this->l10n);
+ $this->filter = new SecurityFilter($this->urlGenerator, $this->l10n);
}
public function testAllowedApps() {
@@ -49,7 +49,7 @@ class GenericFilterTest extends TestCase {
}
public function testFilterTypes() {
- $this->assertEquals(['twofactor'], $this->filter->filterTypes(['comments', 'twofactor']));
+ $this->assertEquals(['security'], $this->filter->filterTypes(['comments', 'security']));
}
public function testGetIcon() {
@@ -65,13 +65,13 @@ class GenericFilterTest extends TestCase {
}
public function testGetIdentifier() {
- $this->assertEquals('twofactor', $this->filter->getIdentifier());
+ $this->assertEquals('security', $this->filter->getIdentifier());
}
public function testGetName() {
$this->l10n->expects($this->once())
->method('t')
- ->with('Two-factor authentication')
+ ->with('Security')
->will($this->returnValue('translated'));
$this->assertEquals('translated', $this->filter->getName());
}
diff --git a/apps/twofactor_backupcodes/tests/Unit/Activity/GenericProviderTest.php b/tests/Settings/Activity/SecurityProviderTest.php
index 242c4ab4e8d..2abc14654f1 100644
--- a/apps/twofactor_backupcodes/tests/Unit/Activity/GenericProviderTest.php
+++ b/tests/Settings/Activity/SecurityProviderTest.php
@@ -20,10 +20,10 @@
*
*/
-namespace OCA\TwoFactorBackupCodes\Test\Unit\Activity;
+namespace Tests\Settings\Activity;
use InvalidArgumentException;
-use OCA\TwoFactorBackupCodes\Activity\GenericProvider;
+use OC\Settings\Activity\SecurityProvider;
use OCP\Activity\IEvent;
use OCP\IL10N;
use OCP\ILogger;
@@ -32,7 +32,7 @@ use OCP\L10N\IFactory;
use PHPUnit_Framework_MockObject_MockObject;
use Test\TestCase;
-class GenericProviderTest extends TestCase {
+class SecurityProviderTest extends TestCase {
/** @var IL10N|PHPUnit_Framework_MockObject_MockObject */
private $l10n;
@@ -43,7 +43,7 @@ class GenericProviderTest extends TestCase {
/** @var ILogger|PHPUnit_Framework_MockObject_MockObject */
private $logger;
- /** @var GenericProvider */
+ /** @var SecurityProvider */
private $provider;
protected function setUp() {
@@ -53,7 +53,7 @@ class GenericProviderTest extends TestCase {
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->logger = $this->createMock(ILogger::class);
- $this->provider = new GenericProvider($this->l10n, $this->urlGenerator, $this->logger);
+ $this->provider = new SecurityProvider($this->l10n, $this->urlGenerator, $this->logger);
}
public function testParseUnrelated() {
@@ -84,7 +84,7 @@ class GenericProviderTest extends TestCase {
$event->expects($this->once())
->method('getType')
- ->willReturn('twofactor');
+ ->willReturn('security');
$this->l10n->expects($this->once())
->method('get')
->with('core', $lang)
@@ -116,7 +116,7 @@ class GenericProviderTest extends TestCase {
$event->expects($this->once())
->method('getType')
- ->willReturn('twofactor');
+ ->willReturn('security');
$this->l10n->expects($this->once())
->method('get')
->with('core', $lang)
diff --git a/apps/twofactor_backupcodes/tests/Unit/Activity/SettingTest.php b/tests/Settings/Activity/SecuritySettingTest.php
index 2f6aed040f0..4e9ce1a0897 100644
--- a/apps/twofactor_backupcodes/tests/Unit/Activity/SettingTest.php
+++ b/tests/Settings/Activity/SecuritySettingTest.php
@@ -20,17 +20,17 @@
*
*/
-namespace OCA\TwoFactorBackupCodes\Test\Unit\Activity;
+namespace Tests\Settings\Activity;
-use OCA\TwoFactorBackupCodes\Activity\GenericSetting;
+use OC\Settings\Activity\SecuritySetting;
use OCP\IL10N;
use Test\TestCase;
-class SettingTest extends TestCase {
+class SecuritySettingTest extends TestCase {
private $l10n;
- /** @var GenericSetting */
+ /** @var SecuritySetting */
private $setting;
protected function setUp() {
@@ -38,7 +38,7 @@ class SettingTest extends TestCase {
$this->l10n = $this->createMock(IL10N::class);
- $this->setting = new GenericSetting($this->l10n);
+ $this->setting = new SecuritySetting($this->l10n);
}
public function testCanChangeMail() {
@@ -50,15 +50,15 @@ class SettingTest extends TestCase {
}
public function testGetIdentifier() {
- $this->assertEquals('twofactor', $this->setting->getIdentifier());
+ $this->assertEquals('security', $this->setting->getIdentifier());
}
public function testGetName() {
$this->l10n->expects($this->once())
->method('t')
- ->with('Two-factor authentication')
- ->will($this->returnValue('Zwei-Faktor-Authentifizierung'));
- $this->assertEquals('Zwei-Faktor-Authentifizierung', $this->setting->getName());
+ ->with('Security')
+ ->will($this->returnValue('Sicherheit'));
+ $this->assertEquals('Sicherheit', $this->setting->getName());
}
public function testGetPriority() {
diff --git a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
index c031c39b5f2..1b5bd9a9e54 100644
--- a/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
+++ b/tests/lib/Authentication/TwoFactorAuth/ManagerTest.php
@@ -260,11 +260,11 @@ class ManagerTest extends TestCase {
->willReturn('jos');
$event->expects($this->once())
->method('setApp')
- ->with($this->equalTo('twofactor_generic'))
+ ->with($this->equalTo('core'))
->willReturnSelf();
$event->expects($this->once())
->method('setType')
- ->with($this->equalTo('twofactor'))
+ ->with($this->equalTo('security'))
->willReturnSelf();
$event->expects($this->once())
->method('setAuthor')
@@ -319,11 +319,11 @@ class ManagerTest extends TestCase {
->willReturn('jos');
$event->expects($this->once())
->method('setApp')
- ->with($this->equalTo('twofactor_generic'))
+ ->with($this->equalTo('core'))
->willReturnSelf();
$event->expects($this->once())
->method('setType')
- ->with($this->equalTo('twofactor'))
+ ->with($this->equalTo('security'))
->willReturnSelf();
$event->expects($this->once())
->method('setAuthor')