Skip to content

Commit 854dc3d

Browse files
[GDPR] fix permission issues when exporting elements
* fix user being able to extract data without element permissions * fix error when extracting pimcore user data due to wrong permission check * Apply php-cs-fixer changes --------- Co-authored-by: wwidergoldpimcore <265217381+wwidergoldpimcore@users.noreply.github.com>
1 parent 5f69ee2 commit 854dc3d

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/Gdpr/Provider/AssetsProvider.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@
1717
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Provider\AssetQueryProviderInterface;
1818
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Query\QueryInterface;
1919
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Service\AssetSearchServiceInterface;
20+
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\ForbiddenException;
2021
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
2122
use Pimcore\Bundle\StudioBackendBundle\Filter\MappedParameter\FilterParameter;
2223
use Pimcore\Bundle\StudioBackendBundle\Gdpr\Provider\Legacy\AssetExporterInterface;
2324
use Pimcore\Bundle\StudioBackendBundle\Gdpr\Schema\GdprDataRow;
2425
use Pimcore\Bundle\StudioBackendBundle\Response\Collection;
26+
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\ElementPermissions;
2527
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions;
2628
use Pimcore\Model\Asset;
2729
use Symfony\Component\HttpFoundation\Response;
30+
use function sprintf;
2831

2932
/**
3033
* @internal
@@ -130,6 +133,10 @@ public function getSingleItemForDownload(int $id): Response
130133
throw new NotFoundException('Asset Not Found', $id);
131134
}
132135

136+
if (!$asset->isAllowed(ElementPermissions::VIEW_PERMISSION)) {
137+
throw new ForbiddenException(sprintf('Access Denied for asset with id "%d".', $asset->getId()));
138+
}
139+
133140
return $this->assetExporter->doExportData($asset);
134141
}
135142

src/Gdpr/Provider/DataObjectProvider.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@
1717
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Provider\DataObjectQueryProviderInterface;
1818
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Query\QueryInterface;
1919
use Pimcore\Bundle\StudioBackendBundle\DataIndex\Service\DataObjectSearchServiceInterface;
20+
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\ForbiddenException;
2021
use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException;
2122
use Pimcore\Bundle\StudioBackendBundle\Filter\MappedParameter\FilterParameter;
2223
use Pimcore\Bundle\StudioBackendBundle\Gdpr\Provider\Legacy\ObjectExporterInterface;
2324
use Pimcore\Bundle\StudioBackendBundle\Gdpr\Schema\GdprDataRow;
2425
use Pimcore\Bundle\StudioBackendBundle\Response\Collection;
26+
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\ElementPermissions;
2527
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions;
2628
use Pimcore\Model\DataObject;
2729
use Pimcore\Model\DataObject\Concrete;
30+
use function sprintf;
2831

2932
/**
3033
* @internal
@@ -132,6 +135,10 @@ public function getSingleItemForDownload(int $id): array
132135
throw new NotFoundException('Requested object is not a Concrete data object', $id);
133136
}
134137

138+
if (!$object->isAllowed(ElementPermissions::VIEW_PERMISSION)) {
139+
throw new ForbiddenException(sprintf('Access Denied for object with id "%d".', $object->getId()));
140+
}
141+
135142
$export = [
136143
'id' => $object->getId(),
137144
'fullPath' => $object->getFullPath(),

src/Gdpr/Provider/PimcoreUserProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,6 @@ public function getSortPriority(): int
213213
*/
214214
public function getRequiredPermissions(): array
215215
{
216-
return [UserPermissions::PIMCORE_USER->value];
216+
return [UserPermissions::USER_MANAGEMENT->value];
217217
}
218218
}

0 commit comments

Comments
 (0)