From b693b5085c3da7a3242c1efe9251c2f579027d76 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Tue, 24 Sep 2013 13:08:55 +0200 Subject: [PATCH 1/4] don't remember login if the encrypion app is enabled because the user needs to log-in again in order to decrypt his private key with his password --- core/templates/login.php | 3 ++- lib/base.php | 1 + lib/util.php | 13 +++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/core/templates/login.php b/core/templates/login.php index ee761f0aa5..3e736f164e 100644 --- a/core/templates/login.php +++ b/core/templates/login.php @@ -32,9 +32,10 @@ t('Lost your password?')); ?> - + + diff --git a/lib/base.php b/lib/base.php index 395d8486a5..b4e12bc7eb 100644 --- a/lib/base.php +++ b/lib/base.php @@ -760,6 +760,7 @@ class OC { || !isset($_COOKIE["oc_token"]) || !isset($_COOKIE["oc_username"]) || !$_COOKIE["oc_remember_login"] + || OC_App::isEnabled('files_encryption') ) { return false; } diff --git a/lib/util.php b/lib/util.php index 41f5f1d16b..ef42ff2aea 100755 --- a/lib/util.php +++ b/lib/util.php @@ -414,10 +414,10 @@ class OC_Util { $encryptedFiles = true; } } - + return $encryptedFiles; } - + /** * @brief Check for correct file permissions of data directory * @paran string $dataDirectory @@ -467,6 +467,7 @@ class OC_Util { } $parameters['alt_login'] = OC_App::getAlternativeLogIns(); + $parameters['encryption_enabled'] = OC_App::isEnabled('files_encryption'); OC_Template::printGuestPage("", "login", $parameters); } @@ -654,16 +655,16 @@ class OC_Util { } return $value; } - + /** * @brief Public function to encode url parameters * * This function is used to encode path to file before output. * Encoding is done according to RFC 3986 with one exception: - * Character '/' is preserved as is. + * Character '/' is preserved as is. * * @param string $component part of URI to encode - * @return string + * @return string */ public static function encodePath($component) { $encoded = rawurlencode($component); @@ -810,7 +811,7 @@ class OC_Util { } } } - + /** * @brief Check if the connection to the internet is disabled on purpose * @return bool From c486fc76089ebc0f421a983e0ef62286e36e533c Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Tue, 24 Sep 2013 18:01:34 +0200 Subject: [PATCH 2/4] introduce OC_Util::rememberLoginAllowed() --- core/templates/login.php | 2 +- lib/base.php | 2 +- lib/util.php | 13 ++++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/core/templates/login.php b/core/templates/login.php index 3e736f164e..06f64d41e3 100644 --- a/core/templates/login.php +++ b/core/templates/login.php @@ -32,7 +32,7 @@ t('Lost your password?')); ?> - + diff --git a/lib/base.php b/lib/base.php index b4e12bc7eb..d0aed230dd 100644 --- a/lib/base.php +++ b/lib/base.php @@ -760,7 +760,7 @@ class OC { || !isset($_COOKIE["oc_token"]) || !isset($_COOKIE["oc_username"]) || !$_COOKIE["oc_remember_login"] - || OC_App::isEnabled('files_encryption') + || !OC_Util::rememberLoginAllowed() ) { return false; } diff --git a/lib/util.php b/lib/util.php index ef42ff2aea..e12f753d5a 100755 --- a/lib/util.php +++ b/lib/util.php @@ -467,7 +467,7 @@ class OC_Util { } $parameters['alt_login'] = OC_App::getAlternativeLogIns(); - $parameters['encryption_enabled'] = OC_App::isEnabled('files_encryption'); + $parameters['rememberLoginAllowed'] = self::rememberLoginAllowed(); OC_Template::printGuestPage("", "login", $parameters); } @@ -509,6 +509,17 @@ class OC_Util { } } + /** + * Check if it is allowed to remember login. + * E.g. if encryption is enabled the user needs to log-in every time he visites + * ownCloud in order to decrypt the private key. + * + * @return bool + */ + public static function rememberLoginAllowed() { + return !OC_App::isEnabled('files_encryption'); + } + /** * @brief Check if the user is a subadmin, redirects to home if not * @return array $groups where the current user is subadmin From 9bb244cc59504b3686b58183315d046084b05fa6 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 26 Sep 2013 19:34:28 +0200 Subject: [PATCH 3/4] check every enabled app if the remember login feature needs to be disabled --- lib/util.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/util.php b/lib/util.php index e12f753d5a..e1bec4aece 100755 --- a/lib/util.php +++ b/lib/util.php @@ -511,13 +511,23 @@ class OC_Util { /** * Check if it is allowed to remember login. - * E.g. if encryption is enabled the user needs to log-in every time he visites - * ownCloud in order to decrypt the private key. + * + * @note Every app can set 'rememberlogin' to 'false' to disable the remember login feature * * @return bool */ public static function rememberLoginAllowed() { - return !OC_App::isEnabled('files_encryption'); + + $apps = OC_App::getEnabledApps(); + + foreach ($apps as $app) { + $appInfo = OC_App::getAppInfo($app); + if (isset($appInfo['rememberlogin']) && $appInfo['rememberlogin'] === 'false') { + return false; + } + + } + return true; } /** From 7e54e8831e1004575ed9feab9a65f11365e4a473 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Thu, 26 Sep 2013 19:34:50 +0200 Subject: [PATCH 4/4] set rememberlogin to false for the encryption app --- apps/files_encryption/appinfo/info.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/files_encryption/appinfo/info.xml b/apps/files_encryption/appinfo/info.xml index 46f1375c98..9d495916d2 100644 --- a/apps/files_encryption/appinfo/info.xml +++ b/apps/files_encryption/appinfo/info.xml @@ -7,6 +7,7 @@ Sam Tuke, Bjoern Schiessle, Florin Peter 4 true + false