Merge pull request #5977 from owncloud/encryption_enable_public_upload
Encryption enable public upload
This commit is contained in:
commit
40231c08cf
8 changed files with 17 additions and 22 deletions
|
@ -108,7 +108,6 @@ if ($needUpgrade) {
|
|||
// if the encryption app is disabled, than everything is fine (INIT_SUCCESSFUL status code)
|
||||
$encryptionInitStatus = 2;
|
||||
if (OC_App::isEnabled('files_encryption')) {
|
||||
$publicUploadEnabled = 'no';
|
||||
$session = new \OCA\Encryption\Session(new \OC\Files\View('/'));
|
||||
$encryptionInitStatus = $session->getInitialized();
|
||||
}
|
||||
|
|
|
@ -261,6 +261,7 @@ class Helper {
|
|||
|
||||
$user = \OCP\User::getUser();
|
||||
|
||||
|
||||
// if we are logged in, then we return the userid
|
||||
if ($user) {
|
||||
return $user;
|
||||
|
|
|
@ -112,19 +112,18 @@ class Keymanager {
|
|||
* @brief store file encryption key
|
||||
*
|
||||
* @param \OC_FilesystemView $view
|
||||
* @param \OCA\Encryption\Util $util
|
||||
* @param string $path relative path of the file, including filename
|
||||
* @param string $catfile keyfile content
|
||||
* @return bool true/false
|
||||
* @note The keyfile is not encrypted here. Client code must
|
||||
* asymmetrically encrypt the keyfile before passing it to this method
|
||||
*/
|
||||
public static function setFileKey(\OC_FilesystemView $view, $path, $catfile) {
|
||||
public static function setFileKey(\OC_FilesystemView $view, $util, $path, $catfile) {
|
||||
|
||||
$proxyStatus = \OC_FileProxy::$enabled;
|
||||
\OC_FileProxy::$enabled = false;
|
||||
|
||||
$userId = Helper::getUser($path);
|
||||
$util = new Util($view, $userId);
|
||||
list($owner, $filename) = $util->getUidAndFilename($path);
|
||||
|
||||
// in case of system wide mount points the keys are stored directly in the data directory
|
||||
|
@ -313,19 +312,16 @@ class Keymanager {
|
|||
/**
|
||||
* @brief store multiple share keys for a single file
|
||||
* @param \OC_FilesystemView $view
|
||||
* @param $path
|
||||
* @param \OCA\Encryption\Util $util
|
||||
* @param string $path
|
||||
* @param array $shareKeys
|
||||
* @return bool
|
||||
*/
|
||||
public static function setShareKeys(\OC_FilesystemView $view, $path, array $shareKeys) {
|
||||
public static function setShareKeys(\OC_FilesystemView $view, $util, $path, array $shareKeys) {
|
||||
|
||||
// $shareKeys must be an array with the following format:
|
||||
// [userId] => [encrypted key]
|
||||
|
||||
$userId = Helper::getUser($path);
|
||||
|
||||
$util = new Util($view, $userId);
|
||||
|
||||
list($owner, $filename) = $util->getUidAndFilename($path);
|
||||
|
||||
// in case of system wide mount points the keys are stored directly in the data directory
|
||||
|
|
|
@ -47,8 +47,10 @@ class Proxy extends \OC_FileProxy {
|
|||
*/
|
||||
private static function shouldEncrypt($path) {
|
||||
|
||||
$userId = Helper::getUser($path);
|
||||
|
||||
if (\OCP\App::isEnabled('files_encryption') === false || Crypt::mode() !== 'server' ||
|
||||
strpos($path, '/' . \OCP\User::getUser() . '/files') !== 0) {
|
||||
strpos($path, '/' . $userId . '/files') !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -244,9 +246,6 @@ class Proxy extends \OC_FileProxy {
|
|||
// split the path parts
|
||||
$pathParts = explode('/', $path);
|
||||
|
||||
// get relative path
|
||||
$relativePath = \OCA\Encryption\Helper::stripUserFilesPath($path);
|
||||
|
||||
// FIXME: handling for /userId/cache used by webdav for chunking. The cache chunks are NOT encrypted
|
||||
if (isset($pathParts[2]) && $pathParts[2] === 'cache') {
|
||||
return $result;
|
||||
|
|
|
@ -91,6 +91,7 @@ class Stream {
|
|||
$this->rootView = new \OC_FilesystemView('/');
|
||||
}
|
||||
|
||||
|
||||
$this->session = new \OCA\Encryption\Session($this->rootView);
|
||||
|
||||
$this->privateKey = $this->session->getPrivateKey();
|
||||
|
@ -527,10 +528,10 @@ class Stream {
|
|||
$this->encKeyfiles = Crypt::multiKeyEncrypt($this->plainKey, $publicKeys);
|
||||
|
||||
// Save the new encrypted file key
|
||||
Keymanager::setFileKey($this->rootView, $this->relPath, $this->encKeyfiles['data']);
|
||||
Keymanager::setFileKey($this->rootView, $util, $this->relPath, $this->encKeyfiles['data']);
|
||||
|
||||
// Save the sharekeys
|
||||
Keymanager::setShareKeys($this->rootView, $this->relPath, $this->encKeyfiles['keys']);
|
||||
Keymanager::setShareKeys($this->rootView, $util, $this->relPath, $this->encKeyfiles['keys']);
|
||||
|
||||
// Re-enable proxy - our work is done
|
||||
\OC_FileProxy::$enabled = $proxyStatus;
|
||||
|
|
|
@ -1093,8 +1093,8 @@ class Util {
|
|||
// Save the recrypted key to it's owner's keyfiles directory
|
||||
// Save new sharekeys to all necessary user directory
|
||||
if (
|
||||
!Keymanager::setFileKey($this->view, $filePath, $multiEncKey['data'])
|
||||
|| !Keymanager::setShareKeys($this->view, $filePath, $multiEncKey['keys'])
|
||||
!Keymanager::setFileKey($this->view, $this, $filePath, $multiEncKey['data'])
|
||||
|| !Keymanager::setShareKeys($this->view, $this, $filePath, $multiEncKey['keys'])
|
||||
) {
|
||||
|
||||
\OCP\Util::writeLog('Encryption library',
|
||||
|
|
|
@ -145,13 +145,15 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase {
|
|||
|
||||
$file = 'unittest-' . time() . '.txt';
|
||||
|
||||
$util = new Encryption\Util($this->view, $this->userId);
|
||||
|
||||
// Disable encryption proxy to prevent recursive calls
|
||||
$proxyStatus = \OC_FileProxy::$enabled;
|
||||
\OC_FileProxy::$enabled = false;
|
||||
|
||||
$this->view->file_put_contents($this->userId . '/files/' . $file, $this->dataShort);
|
||||
|
||||
Encryption\Keymanager::setFileKey($this->view, $file, $key);
|
||||
Encryption\Keymanager::setFileKey($this->view, $util, $file, $key);
|
||||
|
||||
$this->assertTrue($this->view->file_exists('/' . $this->userId . '/files_encryption/keyfiles/' . $file . '.key'));
|
||||
|
||||
|
|
|
@ -152,9 +152,6 @@ if (isset($path)) {
|
|||
$tmpl->assign('sharingToken', $token);
|
||||
$tmpl->assign('disableSharing', true);
|
||||
$allowPublicUploadEnabled = (bool) ($linkItem['permissions'] & OCP\PERMISSION_CREATE);
|
||||
if (\OCP\App::isEnabled('files_encryption')) {
|
||||
$allowPublicUploadEnabled = false;
|
||||
}
|
||||
if (OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes') === 'no') {
|
||||
$allowPublicUploadEnabled = false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue