An open API service indexing awesome lists of open source software.

https://github.com/evansims/openfga-php

Stop writing authorization logic. Start asking questions. OpenFGA high performance relationship-based access control for PHP.
https://github.com/evansims/openfga-php

abac authorization entitlements fga fine-grained-access-control fine-grained-authorization openfga pbac permissions php rbac rebac sdk security zanzibar

Last synced: 16 days ago
JSON representation

Stop writing authorization logic. Start asking questions. OpenFGA high performance relationship-based access control for PHP.

Awesome Lists containing this project

README

          


OpenFGA PHP SDK


codecov
Psalm Type Coverage

Stop writing authorization logic. Start asking questions.

composer require evansims/openfga-php



**Every app needs permissions.** Most developers end up with authorization logic scattered across controllers, middleware, and business logic. Changes break things. New features require touching dozens of files.

**[OpenFGA](https://openfga.dev/) solves this.** Define your authorization rules once, query them anywhere. This SDK provides a modern PHP interface to [OpenFGA](https://openfga.dev/) and [Auth0 FGA](https://auth0.com/fine-grained-authorization).


## Installation

```bash
composer require evansims/openfga-php
```


## Quickstart

```php
use OpenFGA\Client;
use function OpenFGA\{allowed, tuple};

$client = new Client(url: 'http://localhost:8080');

// Instead of scattered if statements in your controllers:
if ($user->isAdmin() || $user->owns($document) || $user->team->canEdit($document)) {
// ...
}

// Ask OpenFGA:
$canEdit = allowed(
client: $client,
store: 'my-store',
model: 'my-model',
tuple: tuple('user:alice', 'editor', 'document:readme')
);

// Zero business logic coupling. Pure authorization.
```

See [the documentation](https://github.com/evansims/openfga-php/wiki) to get started.


## Contributing

Contributions are welcome—have a look at our [contributing guidelines](.github/CONTRIBUTING.md).