v1.5.0
Added
-
Context Management
This release introduces a newcontexthelper function that provides a way to manage ambient context.
This allows you to set a client, store, and model once and use them implicitly by helper functions.use function OpenFGA\{context, objects}; $userId = 'user:alice'; context(function() use ($userId) { // Uses ambient context $editable = objects( user: "user:{$userId}", relation: 'editor', type: 'document', ); print_r($editable); }, client: $client, store: 'my-store', model: 'my-model');
-
New Helper Functions
-
users- Identify who has a particular permission with a resource
There's also newfiltersandfilterhelpers that provide a more concise way to createUserTypeFilterscollections andUserTypeFilterobjects forlistUsersrequests.use function OpenFGA\{users, filter, filters}; $result = users( object: 'document:roadmap', relation: 'viewer', filters: filters( filter('user'), filter('group', 'member'), ), );
-
objects- Retrieve a list of objects a particular user has access to.use function OpenFGA\objects; $result = objects( type: 'document', relation: 'viewer', user: 'user:anne', );
-
checks- Check multiple permissions at once
There's also a newcheckhelper that provides a more concise way to createBatchCheckItemobjects forbatchCheckrequests.use function OpenFGA\{check, checks}; $result = checks( checks: check( user: 'user:anne', relation: 'viewer', object: 'document:roadmap', ), );
-
read- Retrieves all tuples for a particular object.use function OpenFGA\read; $result = read( object: 'document:roadmap', relation: 'viewer', );
-
changes- Retrieves all tuple changes.use function OpenFGA\changes; $result = changes( store: 'my-store', startTime: new DateTimeImmutable('-1 hour'), );
-
Changed
- All helper functions now support omitting
client,store, andmodelparameters when using thecontext()helper. - The
batchhelper has been renamed towrites. - The
allowedhelper now supports omittingtupleparameter.
It now directly accepts user, relation, object and condition as optional parameters.
When no tuple is provided, it will create a tuple for you based on the parameters.
It will throw an exception if no tuple is provided and no parameters are provided.