Search by

anselmocossa / filament-account

anselmocossa

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.

Package info

github.com/anselmocossa/filament-account

pkg:composer/anselmocossa/filament-account

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-12-02 20:18 UTC

This package is auto-updated.

Last update: 2026-12-02 20:22:57 UTC


README

Latest Version on Packagist Total Downloads License

Account for Filament

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 Profile: personal details, verified contacts and, on the right, the account and its protection.

Security Security: the check-up, the ways to sign in, two-step verification and the devices. Recent activity on the right.

Notifications Notifications: the channels, then the channel of each alert, grouped as the application declares them.

Preferences Preferences: saved as you click, with a preview of the formats on the right.

API keys API keys: the permissions, the last use and the expiry of each key, and how to call the API.

Webhooks Webhooks: the events the application offers and how to check the signature.

MCP server MCP server: the address and one-click setup for the assistants that support it.

Activity Activity: grouped by day, searchable, with the last 24 hours and the places you signed in from.

Dark mode Dark mode.

On a phone

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/sanctum with the expires_at column on personal_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:prune removes old activity, ended sessions, expired trusted devices and old webhook deliveries, and deletes the accounts whose grace period is over.
  • account:warn-expiring-keys warns about keys that expire soon and revokes the unused ones.
  • account:send-digests sends 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 in maxApiPermissionsUsing() and canReceiveWebhookUsing().

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.