beranidigital / filament-access
Multi-panel aware fine-grained permissions for Laravel Filament to analyze, generate and inject into all classes and methods in the application. or whatever that means.
Fund package maintenance!
beranidigital
Requires
- php: ^8.1
- filament/filament: ^3.0
- nikic/php-parser: ^5.0
- spatie/laravel-package-tools: ^1.15.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^7.9
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^8.0
- pestphp/pest: ^2.1
- pestphp/pest-plugin-arch: ^2.0
- pestphp/pest-plugin-laravel: ^2.0
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2025-01-08 17:55:50 UTC
README
Multi-panel aware ultra-fine-grained permissions for Laravel Filament to analyze, generate and inject into all classes and methods in the application.
What this package does
- Generate list of almost all Filament component permissions
- Automatically redefine classes to avoid conflict
Why I need this package
- You have too many classes and methods to define permissions one by one
- Default Filament authorization doesn't support multi-panel
What this package doesn't do
- It doesn't provide complete solution for authorization
- It's not meant for custom defined permissions, you need to define it yourself
Installation
You can install the package via composer:
composer require beranidigital/filament-access
You can publish the config file with:
php artisan vendor:publish --tag="filament-access-config"
Usage
\BeraniDigitalID\FilamentAccess\Facades\FilamentAccess::analyzeAll();
or
php artisan filament-access:generate php artisan filament-access:hijack
How it works
- It hooks into a class to correct the permission
- The class will call
Gate::authorize('viewAny', $correctArgument)
with an example ofApp\Filament\Resources\MyResource
as the argument - It's up to you to authorize it with your own custom logic
\Illuminate\Support\Facades\Gate::before(function ($user, $ability, $arguments) { $permission = \BeraniDigitalID\FilamentAccess\Facades\FilamentAccess::determinePermissionName($ability, $arguments); if (!$user->hasPermissionTo($permission)) { return false; } // continue to the next authorization logic });
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.