Prevent objectstore being set from client side

This commit is contained in:
Robin McCorkell 2015-08-25 14:51:47 +01:00
parent 494c1d7417
commit 63218ec098
2 changed files with 16 additions and 2 deletions

View file

@ -138,6 +138,16 @@ abstract class StoragesController extends Controller {
);
}
if ($storage->getBackendOption('objectstore')) {
// objectstore must not be sent from client side
return new DataResponse(
array(
'message' => (string)$this->l10n->t('Objectstore forbidden')
),
Http::STATUS_UNPROCESSABLE_ENTITY
);
}
/** @var Backend */
$backend = $storage->getBackend();
/** @var AuthMechanism */

View file

@ -472,10 +472,14 @@ abstract class StoragesService {
if (!isset($allStorages[$id])) {
throw new NotFoundException('Storage with id "' . $id . '" not found');
}
$oldStorage = $allStorages[$id];
$allStorages[$id] = $updatedStorage;
// ensure objectstore is persistent
if ($objectstore = $oldStorage->getBackendOption('objectstore')) {
$updatedStorage->setBackendOption('objectstore', $objectstore);
}
$allStorages[$id] = $updatedStorage;
$this->writeConfig($allStorages);
$this->triggerChangeHooks($oldStorage, $updatedStorage);