Skip to content

v0.7.0

Choose a tag to compare

@GautierDele GautierDele released this 14 Nov 14:11
733cdac

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, allowed and should returned true by default, query returned the whole table and scoutQuery the whole index. Forgetting ->query(), or adding Scout later without ->scoutQuery(), silently exposed every record. An undeclared callback now throws MissingPerimeterCallbackException when it is used.
  • Controlled queries can no longer widen the caller's own filter (#43). With isolate_parent_query set to false, Post::where('published', true)->controlled() produced published = 1 OR client_id = ?. The perimeters are now always grouped in one nested where.
  • A model without a control fails clearly (#49). controlled() threw "Call to a member function on null"; it now throws MissingControlException.

Fixes

  • Infinite loop on user resolution (#49). When the user model uses HasControl with enabled_by_default on, 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 broken Access alias is removed from composer.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::$controlDiscoveryPaths set in AppServiceProvider is honoured.
  • access:cache and access:clear (#44). They write and remove the list of discovered controls, and are hooked into optimize and optimize: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: the Perimeter constructor 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, and scoutQuery with Scout. Test the screens that list controlled models.
  • The config: remove queries.isolate_parent_query and queries.isolate_perimeter_queries from a published config/access-control.php.
  • HasControl::newControl() now returns Control instead of ?Control.
  • Overridden ControlledPolicy methods must declare a return type compatible with bool|Response.

Full Changelog: v0.6.0...v0.7.0