diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Authentication/TwoFactorAuth/Manager.php | 45 | ||||
-rw-r--r-- | lib/private/Memcache/Memcached.php | 2 | ||||
-rw-r--r-- | lib/private/Server.php | 2 | ||||
-rw-r--r-- | lib/private/Share20/Manager.php | 8 | ||||
-rw-r--r-- | lib/private/legacy/util.php | 4 |
5 files changed, 53 insertions, 8 deletions
diff --git a/lib/private/Authentication/TwoFactorAuth/Manager.php b/lib/private/Authentication/TwoFactorAuth/Manager.php index 48792aa685b..1d0deada696 100644 --- a/lib/private/Authentication/TwoFactorAuth/Manager.php +++ b/lib/private/Authentication/TwoFactorAuth/Manager.php @@ -1,4 +1,5 @@ <?php + /** * @copyright Copyright (c) 2016, ownCloud, Inc. * @@ -26,9 +27,11 @@ use Exception; use OC; use OC\App\AppManager; use OC_App; +use OCP\Activity\IManager; use OCP\AppFramework\QueryException; use OCP\Authentication\TwoFactorAuth\IProvider; use OCP\IConfig; +use OCP\ILogger; use OCP\ISession; use OCP\IUser; @@ -48,15 +51,26 @@ class Manager { /** @var IConfig */ private $config; + /** @var IManager */ + private $activityManager; + + /** @var ILogger */ + private $logger; + /** * @param AppManager $appManager * @param ISession $session * @param IConfig $config + * @param IManager $activityManager + * @param ILogger $logger */ - public function __construct(AppManager $appManager, ISession $session, IConfig $config) { + public function __construct(AppManager $appManager, ISession $session, IConfig $config, IManager $activityManager, + ILogger $logger) { $this->appManager = $appManager; $this->session = $session; $this->config = $config; + $this->activityManager = $activityManager; + $this->logger = $logger; } /** @@ -184,11 +198,40 @@ class Manager { } $this->session->remove(self::SESSION_UID_KEY); $this->session->remove(self::REMEMBER_LOGIN); + + $this->publishEvent($user, 'twofactor_success', [ + 'provider' => $provider->getDisplayName(), + ]); + } else { + $this->publishEvent($user, 'twofactor_failed', [ + 'provider' => $provider->getDisplayName(), + ]); } return $passed; } /** + * Push a 2fa event the user's activity stream + * + * @param IUser $user + * @param string $event + */ + private function publishEvent(IUser $user, $event, array $params) { + $activity = $this->activityManager->generateEvent(); + $activity->setApp('twofactor_generic') + ->setType('twofactor') + ->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']); + } + } + + /** * Check if the currently logged in user needs to pass 2FA * * @param IUser $user the currently logged in user diff --git a/lib/private/Memcache/Memcached.php b/lib/private/Memcache/Memcached.php index dbff6dc2ec2..bf07fd0e6e7 100644 --- a/lib/private/Memcache/Memcached.php +++ b/lib/private/Memcache/Memcached.php @@ -61,7 +61,7 @@ class Memcached extends Cache implements IMemcache { \Memcached::OPT_LIBKETAMA_COMPATIBLE => true, // Enable Binary Protocol - \Memcached::OPT_BINARY_PROTOCOL => true, + //\Memcached::OPT_BINARY_PROTOCOL => true, ]; // by default enable igbinary serializer if available if (\Memcached::HAVE_IGBINARY) { diff --git a/lib/private/Server.php b/lib/private/Server.php index 969e5a25b9b..6f4d4f066e7 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -312,7 +312,7 @@ class Server extends ServerContainer implements IServerContainer { }); $this->registerService(\OC\Authentication\TwoFactorAuth\Manager::class, function (Server $c) { - return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig()); + return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig(), $c->getActivityManager(), $c->getLogger()); }); $this->registerService('NavigationManager', function ($c) { diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index cd1d52c3bbf..6eab5e05a2f 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -1055,8 +1055,10 @@ class Manager implements IManager { public function getShareByToken($token) { $share = null; try { - $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_LINK); - $share = $provider->getShareByToken($token); + if($this->shareApiAllowLinks()) { + $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_LINK); + $share = $provider->getShareByToken($token); + } } catch (ProviderException $e) { } catch (ShareNotFound $e) { } @@ -1072,7 +1074,7 @@ class Manager implements IManager { } } - // If it is not a link share try to fetch a federated share by token + // If it is not a link share try to fetch a mail share by token if ($share === null && $this->shareProviderExists(\OCP\Share::SHARE_TYPE_EMAIL)) { try { $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_EMAIL); diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index 55dc5ae7c15..d97ba37c4c0 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -1381,12 +1381,12 @@ class OC_Util { } /** - * A human readable string is generated based on version, channel and build number + * A human readable string is generated based on version and build number * * @return string */ public static function getHumanVersion() { - $version = OC_Util::getVersionString() . ' (' . OC_Util::getChannel() . ')'; + $version = OC_Util::getVersionString(); $build = OC_Util::getBuild(); if (!empty($build) and OC_Util::getChannel() === 'daily') { $version .= ' Build:' . $build; |