From 1fbdc3ce8fc4c5430b9fd85a95e984a317c75778 Mon Sep 17 00:00:00 2001 From: Florin Peter Date: Wed, 15 May 2013 14:32:50 +0200 Subject: [PATCH 1/2] fix for previous workaround --- apps/files_encryption/appinfo/app.php | 39 ++++++++++++++------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php index ec594fd19f..e56d012fee 100644 --- a/apps/files_encryption/appinfo/app.php +++ b/apps/files_encryption/appinfo/app.php @@ -26,26 +26,27 @@ OCA\Encryption\Helper::registerFilesystemHooks(); stream_wrapper_register( 'crypt', 'OCA\Encryption\Stream' ); -$view = new OC_FilesystemView( '/' ); +// check if we are logged in +if (OCP\User::isLoggedIn()) { + $view = new OC_FilesystemView('/'); + $session = new \OCA\Encryption\Session($view); -//$session = new \OCA\Encryption\Session( $view ); -// -//if ( -// ! $session->getPrivateKey( \OCP\USER::getUser() ) -// && OCP\User::isLoggedIn() -// && OCA\Encryption\Crypt::mode() == 'server' -//) { -// -// // Force the user to log-in again if the encryption key isn't unlocked -// // (happens when a user is logged in before the encryption app is -// // enabled) -// OCP\User::logout(); -// -// header( "Location: " . OC::$WEBROOT.'/' ); -// -// exit(); -// -//} + // check if user has a private key + if ( + !$session->getPrivateKey(\OCP\USER::getUser()) + && OCA\Encryption\Crypt::mode() === 'server' + ) { + + // Force the user to log-in again if the encryption key isn't unlocked + // (happens when a user is logged in before the encryption app is + // enabled) + OCP\User::logout(); + + header("Location: " . OC::$WEBROOT . '/'); + + exit(); + } +} // Register settings scripts OCP\App::registerAdmin( 'files_encryption', 'settings-admin' ); From 63a790b415d0ad54f5d769976ff5c00f1c8df0eb Mon Sep 17 00:00:00 2001 From: Florin Peter Date: Wed, 15 May 2013 14:33:08 +0200 Subject: [PATCH 2/2] fix for broken tests --- apps/files_encryption/hooks/hooks.php | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index ed254fd8d8..16e9f9177d 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -52,16 +52,11 @@ class Hooks { if(Helper::setupUser($util, $params['password']) === false) { return false; } - - \OC_FileProxy::$enabled = false; - + $encryptedKey = Keymanager::getPrivateKey( $view, $params['uid'] ); - \OC_FileProxy::$enabled = true; - - //$privateKey = Crypt::symmetricDecryptFileContent( $encryptedKey, $params['password'] ); - $privateKey = Crypt::symmetricDecryptFileContent( $encryptedKey, "helloworld" ); - + $privateKey = Crypt::symmetricDecryptFileContent( $encryptedKey, $params['password'] ); + $session = new Session( $view ); $session->setPrivateKey( $privateKey, $params['uid'] ); @@ -86,13 +81,9 @@ class Hooks { $session->setLegacyKey( $plainLegacyKey ); } - - \OC_FileProxy::$enabled = false; - + $publicKey = Keymanager::getPublicKey( $view, $params['uid'] ); - \OC_FileProxy::$enabled = false; - // Encrypt existing user files: // This serves to upgrade old versions of the encryption // app (see appinfo/spec.txt)