codersandip / role-permission-visualizer
A visual mapping and conflict detection tool for Laravel Roles & Permissions
Package info
github.com/codersandip/role-permission-visualizer
Language:JavaScript
pkg:composer/codersandip/role-permission-visualizer
Requires
- php: ^8.0.2
- illuminate/support: ^8.0|^9.0|^10.0|^11.0|^12.0
- spatie/laravel-permission: ^5.0|^6.0
Requires (Dev)
- orchestra/testbench: ^6.0|^7.0|^8.0|^9.0
- phpunit/phpunit: ^9.5|^10.0
README
A developer-friendly UI tool to visualize and manage roles, permissions, and users in an interactive graph-based interface. This package extends the functionality of the spatie/laravel-permission ecosystem, providing immediate insights and conflict detection.
๐ Requirements
- PHP
^8.0.2 - Laravel
8.x|9.x|10.x|11.x|12.x spatie/laravel-permission^5.0or^6.0
๐ Features
- Interactive Graph Canvas: Navigate your Access Control List visually using React Flow.
- Color-Coded Nodes: Easily identify Users (orange), Roles (blue), and Permissions (green).
- Intelligent Conflict Detection:
- Spots and alerts you when a user has conflicting roles.
- Detects redundant (duplicate) permission inheritance across multiple roles.
- Filtering System: Toggle visibility between users, roles, and permissions in real-time.
- Exporting: Download an image (
PNG) snapshot of your entire RBAC landscape.
๐ Installation
You can install the package via composer into your local project. Since the package is unpublished, you'll install it from a local file path or custom VCS repository:
composer require codersandip/role-permission-visualizer
Publish the config and the compiled frontend assets to your public directory:
php artisan vendor:publish --tag=visualizer-config php artisan vendor:publish --tag=visualizer-assets
โ๏ธ Configuration
The package comes with sensible defaults. In your config/permission-visualizer.php, you can customize:
return [ 'route' => [ 'prefix' => 'role-permission-visualizer', 'middleware' => ['web', 'visualizer.access'], ], // Overwrite the user model manually, or leave null to automatically extract it from auth.providers. 'user_model' => null, 'cache' => [ 'enabled' => false, 'ttl' => 3600, // 1 hour caching for immense production graphs ], ];
๐ Access Control (Authorization)
By default, the dashboard is only available when the application environment is set to local.
If you want to view it in production, or restrict who can access it locally, you should define a built-in Gate in your App\Providers\AuthServiceProvider boots method:
use Illuminate\Support\Facades\Gate; public function boot() { $this->registerPolicies(); Gate::define('viewRolePermissionVisualizer', function ($user) { // e.g., Only allow Super Admins return $user->hasRole('Super Admin'); }); }
๐ Usage
Simply navigate to:
http://your-app.test/role-permission-visualizer
Use the Sidebar to tweak visibility or evaluate conflicts. Clicking over any node will invoke the contextual Inspector to observe exact DB values mapping.
๐ Development & Modification
Because this package contains a bundled React frontend, if you modify the interface inside resources/js, you need to recompile the assets:
cd vendor/codersandip/role-permission-visualizer
npm install
npm run build
Then republish the assets back to the parent Laravel application.
๐งช Testing
To run the package's testing suite locally:
composer test # or ./vendor/bin/phpunit
๐ License
The MIT License (MIT). Please see License File for more information.