eightcedars / filament-inactivity-guard
Gracefully auto-logout users from idle/inactive Filament sessions
Fund package maintenance!
eightcedars
Installs: 31 167
Dependents: 2
Suggesters: 0
Security: 0
Stars: 22
Watchers: 0
Forks: 5
Open Issues: 1
pkg:composer/eightcedars/filament-inactivity-guard
Requires
- php: ^8.1
- filament/filament: ^4.0 || ^5.0
- livewire/livewire: ^3.0 || ^4.0
- spatie/laravel-package-tools: ^1.16.0
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^8.0
- orchestra/testbench: ^9.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
README
Guard your Filament dashboard from inactive sessions. Log users out after a predefined period of inactivity.
Installation
You can install the package via composer:
composer require eightcedars/filament-inactivity-guard
You can publish the config file with:
php artisan vendor:publish --tag="filament-inactivity-guard-config"
This is the contents of the published config file:
return [ /** * Determine if the plugin is enabled */ 'enabled' => true, /** * How long to wait before an idle session is considered inactive. * This value must be in seconds */ 'inactivity_timeout' => Carbon::SECONDS_PER_MINUTE * env('FILAMENT_IDLE_TIMEOUT', 15), /** * How long to show an inactive session notice before logging the user out. * This value must be in seconds * * Set this to null or 0 to disable the notice and log out immediately a user's session becomes inactive */ 'notice_timeout' => env('FILAMENT_IDLE_WARNING_TIMEOUT', 60), /** * This package watches for a list of browser events to determine if a user is still active. * You may customise as desired. * * Ensure that the list is not empty */ 'interaction_events' => ['mousemove', 'keydown', 'click', 'scroll'], ];
Optionally, you can publish the translation files using
php artisan vendor:publish --tag="filament-inactivity-guard-translations"
You can also publish the view files using
php artisan vendor:publish --tag="filament-inactivity-guard-views"
Usage
Add the plugin class to your panel ServiceProvider
use EightCedars\FilamentInactivityGuard\FilamentInactivityGuardPlugin; $panel ... ->plugin(FilamentInactivityGuardPlugin::make()) ...
You may also configure the plugin behaviour in your service provider instead of publishing and editing the config file:
use EightCedars\FilamentInactivityGuard\FilamentInactivityGuardPlugin;use Illuminate\Support\Carbon;$panel ... ->plugin( FilamentInactivityGuardPlugin::make() ->inactiveAfter(Carbon::SECONDS_PER_MINUTE * 5) ->showNoticeFor(Carbon::SECONDS_PER_MINUTE * 1) // Or set to null to logout immediately after inactivity ->showNoticeFor(null) ->enabled(!app()->isLocal()) ->keepActiveOn(['change', 'select', 'mousemove'], mergeWithDefaults: true), ) ...
You can configure the timeout settings using the following environment variables:
| Variable | Default | Description |
|---|---|---|
FILAMENT_IDLE_TIMEOUT |
15 minutes |
Inactivity period before the logout warning dialog is displayed. |
FILAMENT_IDLE_WARNING_TIMEOUT |
60 seconds |
Duration the logout warning is displayed before the user is automatically logged out. |
Screenshots
Available Languages
馃嚫馃嚘 Arabic (ar) 路 馃嚙馃嚛 Bengali (bn) 路 馃嚚馃嚦 Chinese (Simplified) (zh_CN) 路 馃嚬馃嚰 Chinese (Traditional) (zh_TW) 路 馃嚛馃嚢 Danish (da) 路 馃嚦馃嚤 Dutch (nl) 路 馃嚞馃嚙 English (en) 路 馃嚠馃嚪 Farsi / Persian (fa) 路 馃嚝馃嚠 Finnish (fi) 路 馃嚝馃嚪 French (fr) 路 馃嚛馃嚜 German (de) 路 馃嚠馃嚤 Hebrew (he) 路 馃嚠馃嚦 Hindi (hi) 路 馃嚠馃嚫 Icelandic (is) 路 馃嚠馃嚛 Indonesian (id) 路 馃嚠馃嚬 Italian (it) 路 馃嚡馃嚨 Japanese (ja) 路 馃嚢馃嚪 Korean (ko) 路 馃嚥馃嚲 Malay (ms) 路 馃嚦馃嚧 Norwegian (no) 路 馃嚨馃嚤 Polish (pl) 路 馃嚙馃嚪 Portuguese (Brazil) (pt_BR) 路 馃嚪馃嚭 Russian (ru) 路 馃嚜馃嚫 Spanish (es) 路 馃嚫馃嚜 Swedish (sv) 路 馃嚬馃嚟 Thai (th) 路 馃嚬馃嚪 Turkish (tr) 路 馃嚭馃嚘 Ukrainian (uk) 路 馃嚮馃嚦 Vietnamese (vi)
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.

