Skip to content

Commit

Permalink
minor #3214 Renamed a security permission related to entities (javier…
Browse files Browse the repository at this point in the history
…eguiluz)

This PR was merged into the 3.0.x-dev branch.

Discussion
----------

Renamed a security permission related to entities

We use this permission to check access for index/detail/edit/new pages ... so it's not only about "view entity" but "access to entity" in general. I don't want to introduce different permissions for "view entity", "update entity", etc. because we don't use ACL and if you need that, you can implement it in your own security voter because you always know in which page you are.

Commits
-------

cdf0681 Renamed a security permission related to entities
  • Loading branch information
javiereguiluz committed May 13, 2020
2 parents 1a61200 + cdf0681 commit 38b8837
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Factory/EntityFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function createCollection(EntityDto $entityDto, ?iterable $entityInstance
foreach ($entityInstances as $entityInstance) {
$newEntityDto = $entityDto->newWithInstance($entityInstance);
$newEntityId = $newEntityDto->getPrimaryKeyValueAsString();
if (!$this->authorizationChecker->isGranted(Permission::EA_VIEW_ENTITY, $newEntityDto)) {
if (!$this->authorizationChecker->isGranted(Permission::EA_ACCESS_ENTITY, $newEntityDto)) {
$newEntityDto->markAsInaccessible();
}

Expand All @@ -109,7 +109,7 @@ private function doCreate(?string $entityFqcn = null, $entityId = null, ?string
$entityMetadata = $this->getEntityMetadata($entityFqcn);
$entityDto = new EntityDto($entityFqcn, $entityMetadata, $entityPermission, $entityInstance);

if (!$this->authorizationChecker->isGranted(Permission::EA_VIEW_ENTITY, $entityDto)) {
if (!$this->authorizationChecker->isGranted(Permission::EA_ACCESS_ENTITY, $entityDto)) {
$entityDto->markAsInaccessible();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Security/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
*/
final class Permission
{
public const EA_ACCESS_ENTITY = 'EA_ACCESS_ENTITY';
public const EA_EXECUTE_ACTION = 'EA_EXECUTE_ACTION';
public const EA_VIEW_MENU_ITEM = 'EA_VIEW_MENU_ITEM';
public const EA_VIEW_FIELD = 'EA_VIEW_FIELD';
public const EA_VIEW_ENTITY = 'EA_VIEW_ENTITY';
public const EA_EXIT_IMPERSONATION = 'EA_EXIT_IMPERSONATION';

public static function exists(?string $permissionName): bool
Expand Down
2 changes: 1 addition & 1 deletion src/Security/SecurityVoter.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function voteOnAttribute($permissionName, $subject, TokenInterface $to
return $this->voteOnViewPropertyPermission($subject);
}

if (Permission::EA_VIEW_ENTITY === $permissionName) {
if (Permission::EA_ACCESS_ENTITY === $permissionName) {
return $this->voteOnViewEntityPermission($subject);
}

Expand Down

0 comments on commit 38b8837

Please sign in to comment.