Skip to content

Commit f53a07c

Browse files
committed
Enforce resource listability
1 parent 0c8de3a commit f53a07c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Endpoint/Index.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Psr\Http\Message\ServerRequestInterface as Request;
2020
use Tobyz\JsonApiServer\Adapter\AdapterInterface;
2121
use Tobyz\JsonApiServer\Exception\BadRequestException;
22+
use Tobyz\JsonApiServer\Exception\ForbiddenException;
2223
use Tobyz\JsonApiServer\JsonApi;
2324
use Tobyz\JsonApiServer\ResourceType;
2425
use Tobyz\JsonApiServer\Schema\Attribute;
@@ -51,6 +52,10 @@ public function handle(Context $context): ResponseInterface
5152
$adapter = $this->resource->getAdapter();
5253
$schema = $this->resource->getSchema();
5354

55+
if (! evaluate($schema->isListable(), [$context])) {
56+
throw new ForbiddenException;
57+
}
58+
5459
$query = $adapter->newQuery();
5560

5661
run_callbacks($schema->getListeners('listing'), [$query, $context]);

0 commit comments

Comments
 (0)