Filament Impersonate
A FilamentPHP plugin that lets admins impersonate users with one click and log back out cleanly
Repository Health
Technical Analysis
Filament Impersonate adds an Impersonate table action to FilamentPHP resources so administrators can log in as another user directly from the admin panel, without knowing their password. It tracks the original admin’s identity in the session, fires EnterImpersonation/LeaveImpersonation events, and provides a banner-style “stop impersonating” flow to safely return to the admin account.
The package integrates with Laravel’s multi-guard authentication, supports Laravel’s “remember me” cookies, and lets developers restrict who can be impersonated and by whom via simple authorization callbacks. It is a common addition to admin-facing Filament panels that need customer-support-style “view as user” functionality.
What You Get
- An
Impersonate::make()table action that can be dropped into any Filament resource in one line - Session-based tracking of the impersonating admin so the original identity is preserved and restorable
EnterImpersonationandLeaveImpersonationevents for logging or auditing impersonation activity- Support for Laravel’s multi-guard authentication and “remember me” cookies during impersonation
- Authorization callbacks to control which users can impersonate and which users can be impersonated
- A redirect/banner flow for returning to the original admin account
Common Use Cases
- Customer support staff needing to reproduce a user’s exact view of the application to diagnose an issue
- SaaS admin panels that let super-admins “view as” a tenant user for account troubleshooting
- QA and staging environments where testers need to quickly switch between user accounts
- Auditable admin actions where every impersonation session should fire a loggable event
Under The Hood
Architecture The plugin registers FilamentImpersonateServiceProvider as a Laravel service provider and exposes its behavior through a single ImpersonateManager class (src/ImpersonateManager.php) that stores the impersonator’s ID, guard name, and “remember me” state under fixed session keys (impersonated_by, impersonator_guard), then swaps the authenticated user via Laravel’s SessionGuard; a Filament Impersonate table action (src/Actions/Impersonate.php) is the primary integration point wired into a resource’s table() method. Tech Stack Pure PHP targeting Filament 4/5 and Laravel’s illuminate/auth, tested with Pest 3 and Orchestra Testbench 10, with no other runtime dependencies beyond Filament itself. Code Quality The 15 test files cover the manager’s guard-switching and session logic directly; the manager class centralizes all impersonation state behind named constants rather than scattering session key strings across the codebase, and EnterImpersonation/LeaveImpersonation events give consumers a clean extension point without needing to patch the manager. API Design Setup is a single Impersonate::make() call added to a resource’s table actions, and the manager’s public methods (isImpersonating(), getImpersonator(), getImpersonatorGuardName()) read as plain English, so the learning curve is minimal for anyone already familiar with Filament resources.