Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
throw exception if related collection cannot be accessed
Browse files Browse the repository at this point in the history
Fixes #667
  • Loading branch information
wellingguzman committed Jan 21, 2019
1 parent 1f7e8e7 commit d5edccb
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
@@ -0,0 +1,17 @@
<?php

namespace Directus\Database\Exception;

use Directus\Exception\ForbiddenException;

class ForbiddenFieldAccessException extends ForbiddenException
{
const ERROR_CODE = 215;

public function __construct($field)
{
$message = sprintf('Unable to access "%s" related data', $field);

parent::__construct($message);
}
}
Expand Up @@ -14,6 +14,7 @@
use Directus\Exception\ErrorException;
use Directus\Exception\UnprocessableEntityException;
use Directus\Permissions\Exception\ForbiddenCollectionReadException;
use Directus\Permissions\Exception\ForbiddenFieldReadException;
use Directus\Permissions\Exception\PermissionException;
use Directus\Permissions\Exception\UnableFindOwnerItemsException;
use Directus\Util\ArrayUtils;
Expand Down Expand Up @@ -1198,6 +1199,12 @@ protected function parseDotFilters(Builder $mainQuery, array $filters)
while ($relational) {
$nextTable = SchemaService::getRelatedCollectionName($nextTable, $nextColumn);
$nextColumn = array_shift($columnList);

// Confirm the user has permission to all chained (dot) fields
if ($this->acl && !$this->acl->canRead($nextTable)) {
throw new Exception\ForbiddenFieldAccessException($nextColumn);
}

$relational = SchemaService::hasRelationship($nextTable, $nextColumn);
$columnsTable[] = $nextTable;
}
Expand Down

0 comments on commit d5edccb

Please sign in to comment.