Repository navigation
v0.7.0
The last 0.x release, and a security release: upgrade with composer update lomkit/laravel-access-control. It keeps PHP 8.2 and Laravel 12 support. The next major, 1.0, will require PHP 8.3 and Laravel 13; this release is the safe version for applications that stay on Laravel 12.
Security
Since 0.6.0, three behaviours could expose rows the user was not allowed to see.
- Undeclared perimeter callbacks no longer allow everything (#45). In 0.6,
allowedandshouldreturnedtrueby default,queryreturned the whole table andscoutQuerythe whole index. Forgetting->query(), or adding Scout later without->scoutQuery(), silently exposed every record. An undeclared callback now throwsMissingPerimeterCallbackExceptionwhen it is used. - Controlled queries can no longer widen the caller's own filter (#43). With
isolate_parent_queryset tofalse,Post::where('published', true)->controlled()producedpublished = 1 OR client_id = ?. The perimeters are now always grouped in one nestedwhere. - A model without a control fails clearly (#49).
controlled()threw "Call to a member function on null"; it now throwsMissingControlException.
Fixes
- Infinite loop on user resolution (#49). When the user model uses
HasControlwithenabled_by_defaulton, resolving the authenticated user no longer recurses until the process crashes. - Scout searches without a perimeter (#47). They return an empty page instead of an engine error on Meilisearch and Typesense.
- Policies reuse the registered control (#46). A policy no longer builds a new control on every check.
- README examples (#46). They match the code: the control declares
$model, the policy declares$control. The brokenAccessalias is removed fromcomposer.json. - The registry (#43):
- it starts empty;
- controls are keyed by their class name;
- discovery reads each file's namespace instead of assuming
App\.
New
- Lazy discovery (#44). Controls are discovered the first time one is needed, so
Access::$controlDiscoveryPathsset inAppServiceProvideris honoured. access:cacheandaccess:clear(#44). They write and remove the list of discovered controls, and are hooked intooptimizeandoptimize:clear.- Quality gates (#50, #51). The code is checked by Pint and Larastan level 10, and the Scout integration is tested against real Meilisearch and Typesense servers.
Check after upgrading
- Perimeter classes must not call
parent::__construct()any more: thePerimeterconstructor that set the open defaults is gone (#45), so the call is a fatal error. Remove it. - Perimeters that relied on the open defaults must declare every callback the application uses:
allowed,should,query, andscoutQuerywith Scout. Test the screens that list controlled models. - The config: remove
queries.isolate_parent_queryandqueries.isolate_perimeter_queriesfrom a publishedconfig/access-control.php. HasControl::newControl()now returnsControlinstead of?Control.- Overridden
ControlledPolicymethods must declare a return type compatible withbool|Response.
Full Changelog: v0.6.0...v0.7.0