anselmocossa / filament-account
A complete account area for Filament panels: profile with contacts, security with devices and two-factor by app, e-mail, SMS or WhatsApp, notification preferences per event and channel, personal preferences, API keys, webhooks, an MCP server page and a personal activity log.
Requires
- php: ^8.2
- filament/filament: ^5.0
- illuminate/contracts: ^11.0|^12.0|^13.0
- illuminate/support: ^11.0|^12.0|^13.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- laravel/pint: ^1.0
- laravel/sanctum: ^4.0
- orchestra/testbench: ^9.0|^10.0|^11.0
- pestphp/pest: ^3.0|^4.0
- pestphp/pest-plugin-laravel: ^3.0|^4.0
- pestphp/pest-plugin-livewire: ^3.0|^4.0
- spatie/laravel-permission: ^6.0|^7.0|^8.0
Suggests
- anselmocossa/filament-theme-grafite: to pick the theme on the Preferences page
- laravel/sanctum: for the API keys page
- laravel/socialite: for connected accounts (sign in with Google, Microsoft...)
- spatie/laravel-passkeys: for the passkeys row on the Security page
Provides
None
Conflicts
None
Replaces
None
README
A complete "My account" area for Filament v5 panels. It replaces the panel's profile page with eight pages that share one layout: a menu on the left, the work in the middle and a summary on the right.
- Profile: photo, name and your own extra fields, e-mails and phones verified by code, connected accounts, a copy of your data and account deletion with a grace period.
- Security: a check-up of five recommendations, the password, two-step verification by app, e-mail, SMS or WhatsApp, recovery codes, trusted devices and every device with an open session.
- Notifications: the channel of each alert (in the app, e-mail, SMS, WhatsApp), a daily or weekly digest and "Do not disturb" hours. Security alerts are always on.
- Preferences: language, timezone, date, number and time formats, the first page after signing in, light or dark mode, the theme and accessibility.
- API keys: Sanctum keys with a permission per resource, capped by the person's role, an expiry, an IP allow-list and a warning before they expire.
- Webhooks: signed deliveries with retries, a pause after repeated failures, a test send and the log of each delivery.
- MCP server: the address of your MCP server and one-click setup for Claude, ChatGPT, Cursor, VS Code, Codex and Gemini CLI.
- Activity: what happened with the account in the last 90 days, with "It was me" / "It was not me" and a CSV export.
Everything is configured from AccountPlugin::make(). The plugin uses Filament's own two-step verification,
Sanctum's tokens and Laravel's notifications: it adds tables of its own and no column to users.
Screenshots
Profile: personal details, verified contacts and, on the right, the account and its protection.
Security: the check-up, the ways to sign in, two-step verification and the devices. Recent activity on the right.
Notifications: the channels, then the channel of each alert, grouped as the application declares them.
Preferences: saved as you click, with a preview of the formats on the right.
API keys: the permissions, the last use and the expiry of each key, and how to call the API.
Webhooks: the events the application offers and how to check the signature.
MCP server: the address and one-click setup for the assistants that support it.
Activity: grouped by day, searchable, with the last 24 hours and the places you signed in from.
On a phone the menu becomes a select at the top and the summary goes under the page.
Requirements
- PHP 8.2+, Laravel 11, 12 or 13, Filament 5.
- For API keys:
laravel/sanctumwith theexpires_atcolumn onpersonal_access_tokens(Sanctum 3 and later; an app that started on Sanctum 2 adds it with a migration).
Installation
composer require anselmocossa/filament-account php artisan migrate php artisan filament:assets
The migrations run from the package: there is nothing to publish.
Add the interface and the trait to the user model:
use Filament\Account\Concerns\InteractsWithAccount; use Filament\Account\Contracts\HasAccount; class User extends Authenticatable implements FilamentUser, HasAccount { use InteractsWithAccount; }
HasAccount extends Filament's HasAppAuthentication, HasAppAuthenticationRecovery, HasEmailAuthentication
and HasAvatar, and InteractsWithAccount keeps their data in the account tables.
Register the plugin and Filament's two-step verification in the panel provider:
use Filament\Account\AccountPlugin; use Filament\Auth\MultiFactor\App\AppAuthentication; use Filament\Auth\MultiFactor\Email\EmailAuthentication; $panel ->multiFactorAuthentication([ AppAuthentication::make()->recoverable(), EmailAuthentication::make(), ]) ->plugin(AccountPlugin::make());
The panel's "Profile" item in the user menu becomes "My account", with shortcuts to Security and Notifications.
You do not need ->profile().
A custom login page
The plugin swaps Filament's login page for one that offers "Don't ask for the code on this device". If the panel has its own login page, add the trait to it:
use Filament\Account\Auth\Concerns\TrustsDevices; use Filament\Auth\Pages\Login as BaseLogin; class Login extends BaseLogin { use TrustsDevices; }
Scheduled commands
// routes/console.php Schedule::command('account:prune')->daily(); Schedule::command('account:warn-expiring-keys')->daily(); Schedule::command('account:send-digests')->hourly();
account:pruneremoves old activity, ended sessions, expired trusted devices and old webhook deliveries, and deletes the accounts whose grace period is over.account:warn-expiring-keyswarns about keys that expire soon and revokes the unused ones.account:send-digestssends the daily and weekly digests at each person's hour.
Webhook deliveries and data exports are queued jobs: run a queue worker.
Options
Every option has a default; call only what you want to change.
AccountPlugin::make() // General ->slug('account') // /{panel}/account/profile ->userMenu(replaceProfile: true, security: true, notifications: true) // Pages: true, false or a Closure ->profile()->security()->notifications()->preferences() ->apiKeys()->webhooks()->activity() ->mcp('https://example.com/mcp', name: 'Example', docsUrl: null) // off until it has a URL // Profile ->avatar(true, disk: 'public', directory: 'avatars', maxKb: 2048) ->profileFields([TextInput::make('job_title')]) // saved on users if the column exists, else in the settings ->contacts(emails: true, phones: true, max: 5) ->phoneCountries(['MZ' => '+258', 'ZA' => '+27', 'PT' => '+351']) // the first is the default ->connectedAccounts(['google', 'microsoft']) // needs laravel/socialite ->dataExport(fn (User $user): array => ['orders.csv' => $csv]) // adds your files to the ZIP ->deleteAccount(true, graceDays: 14, using: fn (User $user) => $user->forceDelete()) // Security ->passwordConfirmation(120) // minutes before sensitive actions ask again ->passwordRule(Password::min(12)->letters()->uncompromised()) ->trustedDevices(30) // days; false turns it off ->sessionIdleDays(30) ->smsAuthentication() // codes by SMS or WhatsApp in the two-step verification ->sendSmsUsing(fn (string $phone, string $message) => Sms::send($phone, $message)) ->sendWhatsAppUsing(fn (string $phone, string $message) => WhatsApp::send($phone, $message)) ->passkeys() // needs spatie/laravel-passkeys ->failedLoginsAlert(3) // Notifications ->notificationEvents([ NotificationEvent::make('orders.created') ->label('A new order') ->description('Every order of the shop.') ->group('Shop') ->channels(['database', 'mail', 'sms']) ->default(['database', 'mail']), ]) ->notificationChannels(['database', 'mail', 'sms', 'whatsapp']) ->digest() ->quietHours() ->inboxUrl(fn (): string => route('inbox')) // Preferences ->locales(['pt' => 'Português', 'en' => 'English']) ->timezones(['Africa/Maputo', 'Europe/Lisbon']) // null: every timezone ->landingPages([url('/admin/orders') => 'Orders']) ->accessibility() ->applyPreferences() // language, timezone and formats on every request // API keys ->apiResources(['products' => 'Products', 'orders' => ['label' => 'Orders', 'description' => 'Sales and returns']]) ->maxApiPermissionsUsing(fn (User $user): array => $user->isAdmin() ? [] : ['products' => 'read']) ->apiBaseUrl('https://example.com/api', docsUrl: 'https://example.com/docs') ->apiKeyPrefix('ex_') ->apiKeyLimit(10) ->apiKeyExpiry(defaultDays: 90, warningDays: 14, allowWithoutExpiry: false) ->revokeUnusedKeysAfter(90) ->apiKeyIpRestriction() // Webhooks ->webhookEvents(['Shop' => ['order.created' => 'An order is placed', 'order.paid' => 'An order is paid']]) ->canReceiveWebhookUsing(fn (User $user, string $event): bool => $user->can('view orders')) ->webhookHeaders('Example') // Example-Event, Example-Delivery, Example-Signature ->webhookRetries(retries: 8, pauseAfter: 15) ->webhookTimeout(10) ->webhookSourceIps(['203.0.113.10']) ->webhookDocsUrl('https://example.com/docs/webhooks') ->webhookQueue('webhooks') // MCP server ->mcpTools(fn (User $user): array => ['read' => 41, 'write' => 38]) ->mcpAuthorizations(fn (User $user): iterable => [...], revoke: fn (User $user, string $id) => ...) // Activity ->activityRetentionDays(90) ->activityPerPage(25) ->locateIpUsing(fn (string $ip): ?string => GeoIp::cityAndCountry($ip));
php artisan vendor:publish --tag=filament-account-config publishes config/account.php with the same options,
for values you prefer to keep out of the panel provider.
Using it from your application
Notifications that follow the person's choices
Declare the alert with notificationEvents() and ask the plugin for the channels in via(). It applies the
channel of that alert, the channels that are off and "Do not disturb":
use Filament\Account\Account; class OrderCreated extends Notification { public function via(object $notifiable): array { return Account::channelsFor($notifiable, 'orders.created'); } public function toSms(object $notifiable): string { return "New order {$this->order->number}."; } }
toSms() and toWhatsApp() return the text; it goes to the person's primary phone through sendSmsUsing() or
sendWhatsAppUsing().
Webhooks
Account::dispatchWebhook('order.created', ['id' => $order->id, 'total' => $order->total]);
Every active webhook that listens to the event, and whose owner may receive it, gets a POST with a JSON body
{"event": ..., "created_at": ..., "data": {...}} and the headers Webhook-Event, Webhook-Delivery and
Webhook-Signature: t=<timestamp>,v1=<hmac>. The HMAC is SHA-256 of "<timestamp>.<body>" with the webhook's
secret. A failed delivery is retried with a growing wait; after the set number of failures in a row the webhook
pauses and its owner is told.
Only HTTPS addresses that resolve to public IP addresses are accepted, and the connection goes to the address that was checked.
API keys
A key gets the Sanctum abilities {resource}:read and, for write, {resource}:write. Check them as usual:
Route::middleware(['auth:sanctum', 'abilities:orders:read'])->get('/orders', ...);
Keys with an IP allow-list are refused from other addresses. The plugin records the last IP and use of each key. Tokens your application makes itself are left alone.
Activity
The plugin records sign-ins, failed sign-ins, sign-outs and every change made in the account area. Add your own lines with:
Account::log($user, 'orders.exported', ['count' => 120]);
A line shows the text of filament-account::{group}.activity.{event} when the translation exists.
Works with
anselmocossa/filament-theme-grafite: Preferences offers the themes the panel published.- A notifications inbox: set its address with
inboxUrl()and Notifications links to it. Filament's database notifications give the unread count. spatie/laravel-permission(and Filament Shield): the roles show on the profile; use them inmaxApiPermissionsUsing()andcanReceiveWebhookUsing().
A note for page authors
Filament renders a hidden action as a disabled button when a view echoes it directly. The account views wrap such
echoes in @if ($this->someAction->isVisible()); do the same if you publish and change the views.
Translations
English, Portuguese (pt) and European Portuguese (pt_PT).
php artisan vendor:publish --tag=filament-account-translations
Testing
composer test
Changelog
See CHANGELOG.
Security
See SECURITY for how to report a vulnerability.
License
The MIT License (MIT). See LICENSE.

