Check for e2e encryption when changing exif data
parent
1167365f7e
commit
5078d986da
|
@ -32,6 +32,7 @@ use OCP\App\IAppManager;
|
||||||
use OCP\AppFramework\Controller;
|
use OCP\AppFramework\Controller;
|
||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\JSONResponse;
|
use OCP\AppFramework\Http\JSONResponse;
|
||||||
|
use OCP\Encryption\IManager;
|
||||||
use OCP\Files\File;
|
use OCP\Files\File;
|
||||||
use OCP\Files\Folder;
|
use OCP\Files\Folder;
|
||||||
use OCP\Files\IRootFolder;
|
use OCP\Files\IRootFolder;
|
||||||
|
@ -48,6 +49,7 @@ class ApiBase extends Controller
|
||||||
protected IUserSession $userSession;
|
protected IUserSession $userSession;
|
||||||
protected IRootFolder $rootFolder;
|
protected IRootFolder $rootFolder;
|
||||||
protected IAppManager $appManager;
|
protected IAppManager $appManager;
|
||||||
|
protected IManager $encryptionManager;
|
||||||
protected TimelineQuery $timelineQuery;
|
protected TimelineQuery $timelineQuery;
|
||||||
protected TimelineWrite $timelineWrite;
|
protected TimelineWrite $timelineWrite;
|
||||||
protected IShareManager $shareManager;
|
protected IShareManager $shareManager;
|
||||||
|
@ -60,6 +62,7 @@ class ApiBase extends Controller
|
||||||
IDBConnection $connection,
|
IDBConnection $connection,
|
||||||
IRootFolder $rootFolder,
|
IRootFolder $rootFolder,
|
||||||
IAppManager $appManager,
|
IAppManager $appManager,
|
||||||
|
IManager $encryptionManager,
|
||||||
IShareManager $shareManager,
|
IShareManager $shareManager,
|
||||||
IPreview $preview
|
IPreview $preview
|
||||||
) {
|
) {
|
||||||
|
@ -70,6 +73,7 @@ class ApiBase extends Controller
|
||||||
$this->connection = $connection;
|
$this->connection = $connection;
|
||||||
$this->rootFolder = $rootFolder;
|
$this->rootFolder = $rootFolder;
|
||||||
$this->appManager = $appManager;
|
$this->appManager = $appManager;
|
||||||
|
$this->encryptionManager = $encryptionManager;
|
||||||
$this->shareManager = $shareManager;
|
$this->shareManager = $shareManager;
|
||||||
$this->previewManager = $preview;
|
$this->previewManager = $preview;
|
||||||
$this->timelineQuery = new TimelineQuery($connection);
|
$this->timelineQuery = new TimelineQuery($connection);
|
||||||
|
|
|
@ -75,6 +75,11 @@ class ImageController extends ApiBase
|
||||||
return new JSONResponse([], Http::STATUS_FORBIDDEN);
|
return new JSONResponse([], Http::STATUS_FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for end-to-end encryption
|
||||||
|
if (\OCA\Memories\Util::isEncryptionEnabled($this->encryptionManager)){
|
||||||
|
return new JSONResponse(['message' => 'Cannot change encrypted file'], Http::STATUS_PRECONDITION_FAILED);
|
||||||
|
}
|
||||||
|
|
||||||
// Get original file from body
|
// Get original file from body
|
||||||
$exif = $this->request->getParam('raw');
|
$exif = $this->request->getParam('raw');
|
||||||
$path = $file->getStorage()->getLocalFile($file->getInternalPath());
|
$path = $file->getStorage()->getLocalFile($file->getInternalPath());
|
||||||
|
|
13
lib/Util.php
13
lib/Util.php
|
@ -105,4 +105,17 @@ class Util
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if any encryption is enabled that we can not cope with
|
||||||
|
* such as end-to-end encryption
|
||||||
|
*/
|
||||||
|
public static function isEncryptionEnabled(&$encryptionManager): bool
|
||||||
|
{
|
||||||
|
if ($encryptionManager->isEnabled()){
|
||||||
|
// Server-side encryption (OC_DEFAULT_MODULE) is okay, others like e2e are not
|
||||||
|
return $encryptionManager->getDefaultEncryptionModuleId() != 'OC_DEFAULT_MODULE';
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue