Manage Laravel Sanctum personal access tokens from your Filament panel.
Install the package and Sanctum:
composer require devtical/filament-sanctum laravel/sanctumPublish Sanctum and run migrations:
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
php artisan migrateAdd the HasApiTokens trait to your user model:
use Laravel\Sanctum\HasApiTokens;
class User extends Authenticatable
{
use HasApiTokens;
}Register the plugin in your Filament panel provider:
use Devtical\Sanctum\SanctumPlugin;
public function panel(Panel $panel): Panel
{
return $panel
// ...
->plugin(SanctumPlugin::make());
}Publish the package config (optional):
php artisan vendor:publish --tag=filament-sanctum-configPublish translations (optional):
php artisan vendor:publish --tag=filament-sanctum-translationsBy default, the Sanctum page appears in the user menu. To show it in the sidebar instead:
// config/filament-sanctum.php
'navigation' => [
'slug' => 'sanctum',
'sidebar_menu' => [
'enabled' => true,
],
'user_menu' => [
'enabled' => false,
],
],Customize the abilities available when creating a token:
'abilities' => [
'columns' => 4,
'allow_expiration' => true,
'default_expiration_days' => 30,
'expiration_presets' => [7, 30, 60, 90],
'list' => [
'posts:read' => 'Read posts',
'posts:write' => 'Write posts',
],
],Restrict access to the Sanctum page using a Laravel gate:
'authorization' => [
'enabled' => true,
'gate' => 'manage-api-tokens',
],Define the gate in a service provider:
Gate::define('manage-api-tokens', fn (User $user) => $user->isAdmin());composer testFormat code:
composer formatPlease see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email w.kristories@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.

