Skip to content

Commit 46bf8fa

Browse files
authored
[Tag]: Allow tags_search permission on GET tag endpoints (#1796)
1 parent 90d2eef commit 46bf8fa

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

src/Tag/Controller/CollectionController.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\TagsParameters;
2929
use Pimcore\Bundle\StudioBackendBundle\Tag\Schema\Tag;
3030
use Pimcore\Bundle\StudioBackendBundle\Tag\Service\TagServiceInterface;
31+
use Pimcore\Bundle\StudioBackendBundle\Security\PermissionsToCheck;
3132
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
3233
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions;
3334
use Pimcore\Bundle\StudioBackendBundle\Util\Trait\PaginatedResponseTrait;
3435
use Symfony\Component\HttpFoundation\JsonResponse;
3536
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
3637
use Symfony\Component\Routing\Attribute\Route;
37-
use Symfony\Component\Security\Http\Attribute\IsGranted;
3838
use Symfony\Component\Serializer\SerializerInterface;
3939

4040
/**
@@ -55,7 +55,6 @@ public function __construct(
5555
* @throws InvalidQueryTypeException
5656
*/
5757
#[Route('/tags', name: 'pimcore_studio_api_tags', methods: ['GET'])]
58-
#[IsGranted(UserPermissions::TAGS_CONFIGURATION->value)]
5958
#[Get(
6059
path: self::PREFIX . '/tags',
6160
operationId: 'tag_get_collection',
@@ -81,6 +80,14 @@ public function __construct(
8180
public function getTags(
8281
#[MapQueryString] TagsParameters $parameters): JsonResponse
8382
{
83+
$this->denyAccessUnlessGranted(
84+
'HasOneOf',
85+
new PermissionsToCheck([
86+
UserPermissions::TAGS_CONFIGURATION->value,
87+
UserPermissions::TAGS_SEARCH->value,
88+
])
89+
);
90+
8491
return $this->jsonResponse(['items' => $this->tagService->listTags($parameters)]);
8592
}
8693
}

src/Tag/Controller/GetController.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
2323
use Pimcore\Bundle\StudioBackendBundle\Tag\Schema\Tag;
2424
use Pimcore\Bundle\StudioBackendBundle\Tag\Service\TagServiceInterface;
25+
use Pimcore\Bundle\StudioBackendBundle\Security\PermissionsToCheck;
2526
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
2627
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions;
2728
use Symfony\Component\HttpFoundation\JsonResponse;
2829
use Symfony\Component\Routing\Attribute\Route;
29-
use Symfony\Component\Security\Http\Attribute\IsGranted;
3030
use Symfony\Component\Serializer\SerializerInterface;
3131

3232
/**
@@ -42,7 +42,6 @@ public function __construct(
4242
}
4343

4444
#[Route('/tags/{id}', name: 'pimcore_studio_api_get_tag', methods: ['GET'])]
45-
#[IsGranted(UserPermissions::TAGS_CONFIGURATION->value)]
4645
#[Get(
4746
path: self::PREFIX . '/tags/{id}',
4847
operationId: 'tag_get_by_id',
@@ -61,6 +60,14 @@ public function __construct(
6160
])]
6261
public function getTags(int $id): JsonResponse
6362
{
63+
$this->denyAccessUnlessGranted(
64+
'HasOneOf',
65+
new PermissionsToCheck([
66+
UserPermissions::TAGS_CONFIGURATION->value,
67+
UserPermissions::TAGS_SEARCH->value,
68+
])
69+
);
70+
6471
return $this->jsonResponse($this->tagService->getTag($id));
6572
}
6673
}

0 commit comments

Comments
 (0)