thewunder / chiphpotle-bundle
Symfony Bundle for the the Chiphpotle SpiceDB client
dev-master
2024-12-07 19:44 UTC
Requires
- php: >=8.1
- alsbury/chiphpotle-rest: ^0.7
- symfony/config: ^6.1|^7.0
- symfony/dependency-injection: ^6.1|^7.0
- symfony/http-kernel: ^6.1|^7.0
This package is auto-updated.
Last update: 2024-12-07 19:44:58 UTC
README
This package integrates the Chiphpotle Rest SpiceDB client into Symfony, and makes it available as a service. This is a bare-bones integration that only provides the raw client.
Install using:
composer require thewunder/chiphpotle-bundle
Configure your rest connection in config/packages/chiphpotle.yaml
chiphpotle: base_url: http secret: SuperSecrit
And then it will be available for auto-wiring in your classes, assuming you have symfony flex enabled.
use Chiphpotle\Rest\Client; use Chiphpotle\Rest\Model\CheckPermissionRequest; use Chiphpotle\Rest\Model\ObjectReference; use Chiphpotle\Rest\Model\SubjectReference; use Chiphpotle\Rest\Enum\Permissionship; class MyPermissionService { public function __construct(private readonly Client $spiceDB) { } public function check(ObjectReference $object, string $permission, SubjectReference $subject): bool { $response = $this->spiceDB->checkPermission(new CheckPermissionRequest($object, $permission, $subject)); return $response->getPermissionship() == Permissionship::HAS_PERMISSION; } //...