Skip to content

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

License

Notifications You must be signed in to change notification settings

evansims/openfga-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 solves this. Define your authorization rules once, query them anywhere. This SDK provides a modern PHP interface to OpenFGA and Auth0 FGA.


Installation

composer require evansims/openfga-php


Quickstart

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 to get started.


Contributing

Contributions are welcome—have a look at our contributing guidelines.

About

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

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Contributors 5

Languages