- How do I integrate Sanctum token management into my existing Filament 4 admin panel?
- Install via Composer (`composer require devtical/filament-sanctum`), publish the config and translations, then register the plugin in your `AdminPanelProvider`. The package extends Filament’s resource system to handle Sanctum tokens without modifying core Sanctum behavior.
- Does this package work with Laravel Sanctum v3+ and Filament 4 only?
- Yes, it’s explicitly designed for Filament 4 and Sanctum v3+. While it likely works with Laravel 10/11, always pin Sanctum’s version in `composer.json` to avoid compatibility issues. Downgrading Filament or Sanctum may require manual adjustments.
- Can I use this package if I’ve customized Sanctum’s default token generator or guards?
- The package assumes standard Sanctum configurations. If you’ve overridden Sanctum’s behavior (e.g., custom guards or token generators), you’ll need to extend the package’s models or configurations. Document these customizations early to avoid conflicts.
- Will this package slow down my admin panel if I have thousands of API tokens?
- Token listings could impact performance without pagination. Configure Sanctum’s `PersonalAccessToken` model queries (e.g., `withTrashed()`) or enable Filament’s built-in pagination for token tables. Test under load to ensure responsiveness.
- How do I align Filament’s RBAC (roles/permissions) with Sanctum token permissions?
- The package doesn’t enforce RBAC by default. If your Filament admin uses packages like `spatie/laravel-permission`, ensure Sanctum’s `hasAccess()` checks align with your role policies. Override policies in `AuthServiceProvider` if needed.
- Does this package support multi-tenancy in Laravel?
- No, the package doesn’t natively handle multi-tenancy. If using Laravel’s multi-tenancy (e.g., `stancl/tenancy`), ensure Sanctum’s `hasAccess()` checks respect tenant contexts. You may need to extend the package’s token policies for tenant-aware validation.
- Can I audit token creation/revocation events in Filament?
- The package doesn’t include built-in audit logging, but you can integrate it with Filament’s audit log or a third-party solution like `spatie/laravel-activitylog`. Configure Sanctum’s events to log token changes and sync them with your audit system.
- Will this conflict with other Filament plugins like Spatie’s Laravel Permission?
- Conflicts are unlikely if plugins don’t extend Sanctum resources. Test with `filament/spatie-laravel-permission` by verifying token CRUD operations and permission checks. If issues arise, check for overlapping resource definitions in plugin configurations.
- How do I test token management in Filament before deploying to production?
- Run `composer test` to execute the package’s unit tests. Manually test token creation, revocation, and listing in Filament’s UI, then validate API responses match UI actions. Use `sanctum:flush` cautiously in testing to avoid disrupting active API requests.
- What’s the best way to migrate from manual Sanctum token management to this package?
- Audit your existing Sanctum setup (e.g., custom token generators, guards) and back up `config/sanctum.php`. Install the package, publish configs, and register the plugin. Gradually replace manual token workflows with Filament’s UI, testing API consistency at each step.