devtical/filament-sanctum
Filament Sanctum adds a Filament panel for managing Laravel Sanctum API tokens. Create and view personal access tokens from the admin UI, with publishable config and translations for easy customization.
Manage Laravel Sanctum personal access tokens from your Filament panel.
Install the package and Sanctum:
composer require devtical/filament-sanctum laravel/sanctum
Publish Sanctum and run migrations:
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
php artisan migrate
Add 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-config
Publish translations (optional):
php artisan vendor:publish --tag=filament-sanctum-translations
By 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 test
Format code:
composer format
Please 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.
How can I help you explore Laravel packages today?