filagora/filagora-entitlements
| Install | |
|---|---|
composer require filagora/filagora-entitlements |
|
| Latest Version: | v0.2.6 |
| PHP: | ^8.4 |
| Laravel: | 11 · 12 · 13 |
| License: | MIT |
| Last Updated: | Nov 14, 2026 |
| Links: | GitHub · Packagist |
Filagora Entitlements
Entitlement definitions, user and default grants, requests, a cached resolver and the
authorization service for Filagora, as a Laravel 13 / Filament 5 plugin. An entitlement is a
named permission such as forums.read; users hold them through grants, and everything else in
Filagora asks "may this user do this?" through one service. Requires
filagora/filagora-core.
0.x: the API may change between minor versions.
What it provides
Overview
Entitlements for Filagora: definitions, grants, requests, a cached resolver and the authorization service.
Tables
entitlement_definitions, default_entitlement_grants, user_entitlement_grants, entitlement_requests, prefixed filagora_ by default. A site that already has them can run php artisan filagora:adopt instead of migrating.
Commands
| Command | What it does |
|---|---|
filagora:entitlements:sync |
Create entitlement definitions for every key declared by packages or used by grants. |
Events
EntitlementRequestApproved: Dispatched after a request is approved by a reviewer.EntitlementRequestRejected: Dispatched after a request is rejected by a reviewer.EntitlementRequestRevoked: Dispatched after a request is revoked by a reviewer.
Access
| Ability | Entitlement key |
|---|---|
filagora.settings.manage |
filagora.settings.manage |
filagora.entitlements.manage |
filagora.entitlements.manage |
filagora.entitlements.view |
filagora.entitlements.view |
Using it
- Tables and models for definitions, user grants, default grants and requests
(
EntitlementDefinition,UserEntitlementGrant,DefaultEntitlementGrant,EntitlementRequest). EntitlementResolverworks out what a user holds from default grants (all users, authenticated users or verified users), direct grants (with start, expiry and revocation) and grants other packages contribute. Wildcards work: a grant ofapi.plugins.*coversapi.plugins.read. Results are cached per user under a versioned key that is invalidated the moment a grant changes, and memoised for the request.explain()says where an entitlement came from.AuthorizationService:allows,allowsAnyandallowsAll, the single place that answers authorization questions. Policies can use theAuthorizesWithEntitlementstrait. It is also bound as core'sAccessChecker, which is what the other Filagora packages ask whether a user may use a staff screen, so installing this package is all they need. To use something else (roles, a permissions package), bind your ownFilagora\Core\Contracts\AccessCheckerin your application's service provider; the other packages then follow it.- Privacy. Registers a
PrivacyContributorwith core: a person's grants and requests for an export, and their deletion (clearing the cache) for an erasure. Withfilagora-complianceinstalled, privacy requests use it. - Filament screens for definitions, user grants, default grants and a request queue with approve, reject and revoke, plus two relation managers for your own user resource.
- Actions and events for reviewing requests:
ApproveEntitlementRequest,RejectEntitlementRequest,RevokeEntitlementRequest, and the matchingEntitlementRequestApproved,EntitlementRequestRejectedandEntitlementRequestRevokedevents. filagora:entitlements:synccreates a definition for every key packages declare or grants use. It only creates: a definition staff have edited is never overwritten.filagora:adoptsupport: the package ships a snapshot of its four tables, so a site that already has them can adopt them (see core).
Access control
Every screen is denied until the user holds the matching entitlement. Each screen is guarded
by a Gate ability, and gates in the config maps the ability to the entitlement that opens it:
| Gate ability | Opens | Default entitlement key |
|---|---|---|
filagora.entitlements.manage |
Definitions, user grants, default grants, the user relation manager for grants | filagora.entitlements.manage |
filagora.entitlements.view |
The request queue and reviewing requests, the user relation manager for requests | filagora.entitlements.view |
filagora.settings.manage |
Core's settings screen | filagora.settings.manage |
A single wildcard grant, filagora.*, opens all of them. To use your own keys, change the right
side of the map in config/filagora-entitlements.php:
'gates' => [
'filagora.entitlements.manage' => 'admin.entitlements.manage',
],
Keys in the map are created as definitions by filagora:entitlements:sync.
Using it in your app
-
Add the optional trait to your user model:
use \Filagora\Entitlements\Concerns\HasEntitlements;(the relations to grants and requests, andhasEntitlement()). Filagora never alters youruserstable. -
Attach the relation managers to your own user resource:
UserEntitlementsRelationManagerandUserEntitlementRequestsRelationManager. -
Ask questions through the service:
app(\Filagora\Entitlements\Services\AuthorizationService::class)->allows($user, 'forums.read');or
Gate::allows('filagora.entitlements.manage')for the abilities above.
Requirements
PHP 8.4, Laravel 13 and Filament 5. Tested against MariaDB 11.4. Requires filagora/filagora-core.
Install
composer require filagora/filagora-entitlements
php artisan migrate
php artisan filagora:entitlements:sync # creates definitions for the keys packages declare
Register both plugins on a Filament panel:
->plugins([
\Filagora\Core\FilagoraCorePlugin::make(),
\Filagora\Entitlements\FilagoraEntitlementsPlugin::make(),
])
Publish the config if you want to change it: php artisan vendor:publish --tag=filagora-entitlements-config.
Configuration
| Key | Environment | Default | Meaning |
|---|---|---|---|
cache_ttl_seconds |
FILAGORA_ENTITLEMENTS_CACHE_TTL |
300 |
Upper bound on how long a user's resolved entitlements are cached (minimum 30). Changes made through the package take effect immediately regardless |
gates |
the three above | Gate ability to entitlement key |
Extending
- Declare your keys:
app(EntitlementRegistry::class)->define(new Definition('forums.read', label: 'Read forums')). Packages declare the entitlements they own this way;EntitlementKeySourcelists further keys (for example those set on forums). - Grants from elsewhere (a memberships add-on, say): implement
GrantSourceand register it withEntitlementRegistry::grantSource(). The resolver merges its grants with the rest. - A super-user bypass: bind your own
SuperUserCheckin the container to grant every entitlement to certain users (for example a role). The default bypasses nobody.
Testing
composer test
Tests run against a real MariaDB, never SQLite, so engine behaviour (FULLTEXT,
ONLY_FULL_GROUP_BY, collation) matches production. Host and credentials come from
your environment; the database is always named testing, never your development one.
Local development (DDEV)
.ddev/ is included. ddev start creates both db and testing (run ddev restart once
if testing is missing), then ddev exec vendor/bin/pest.
Licence
MIT. See LICENSE.
Related Packages
Filagora core: module registry, settings and shared support for the Filagora Fil...
A Filament plugin for database-backed application settings and editable content,...
Version History
| Version | Released | PHP | License |
|---|---|---|---|
| v0.2.6 | ^8.4 | MIT | |
| v0.2.5 | ^8.4 | MIT | |
| v0.2.4 | ^8.4 | MIT | |
| v0.2.3 | ^8.4 | MIT | |
| v0.2.2 | ^8.4 | MIT | |
| v0.2.1 | ^8.4 | MIT | |
| v0.2.0 | ^8.4 | MIT | |
| v0.1.1 | ^8.4 | MIT | |
| v0.1.0 | ^8.4 | MIT |