PHPackages                             chuimi/filament-impersonation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Admin Panels](/categories/admin)
4. /
5. chuimi/filament-impersonation

ActiveLibrary[Admin Panels](/categories/admin)

chuimi/filament-impersonation
=============================

Controlled user impersonation plugin for Filament applications.

v0.1.1(2mo ago)027↑55.6%[3 issues](https://github.com/it-chuimi/filament-impersonation/issues)MITPHPPHP ^8.2CI passing

Since May 19Pushed 1mo agoCompare

[ Source](https://github.com/it-chuimi/filament-impersonation)[ Packagist](https://packagist.org/packages/chuimi/filament-impersonation)[ Docs](https://github.com/it-chuimi/filament-impersonation)[ RSS](/packages/chuimi-filament-impersonation/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (8)Versions (5)Used By (0)

Filament Impersonation
======================

[](#filament-impersonation)

[![Tests](https://github.com/it-chuimi/filament-impersonation/actions/workflows/tests.yml/badge.svg)](https://github.com/it-chuimi/filament-impersonation/actions/workflows/tests.yml)

Controlled and audited user impersonation plugin for Laravel and Filament applications.

Allows an authorized operator to temporarily authenticate as another user while preserving a mandatory audit trail of the real operator.

Requirements
------------

[](#requirements)

- PHP &gt;= 8.2
- Laravel &gt;= 12
- Filament &gt;= 5
- [spatie/laravel-activitylog](https://github.com/spatie/laravel-activitylog)
- [spatie/laravel-permission](https://github.com/spatie/laravel-permission) *(optional — required only for role/permission-based authorization)*

Installation
------------

[](#installation)

```
composer require chuimi/filament-impersonation
```

Publish the configuration file:

```
php artisan vendor:publish --tag=filament-impersonation-config
```

Minimal setup
-------------

[](#minimal-setup)

Installing the package alone is not enough for the impersonation action to appear in the UI. The plugin must be registered in a panel and the action must be added to a resource explicitly.

The package does not auto-register in any Filament panel or inject the action into any resource. This is intentional — applications may have multiple panels and different authorization policies per context.

**1. Install and publish config**

```
composer require chuimi/filament-impersonation:^0.1.1
php artisan vendor:publish --tag=filament-impersonation-config
```

**2. Set required configuration**

In `config/filament-impersonation.php`, configure at minimum `guard`, `user_model`, an authorization rule (`operator_roles` or `can_impersonate`), and `protected_roles`.

**3. Register the plugin in your panel — required for the banner**

```
use Chuimi\FilamentImpersonation\Filament\ImpersonationPlugin;

->plugins([ImpersonationPlugin::make()])
```

**4. Add the action to the users table — required for the trigger**

```
use Chuimi\FilamentImpersonation\Filament\Actions\ImpersonateAction;

->actions([ImpersonateAction::make()])
```

**5. Clear caches**

```
php artisan optimize:clear
```

For a detailed checklist including config examples, redirects, and manual verification steps see [Integration guide — Minimal setup checklist](docs/INTEGRATION.md#minimal-setup-checklist-for-first-time-consumers).

Usage
-----

[](#usage)

### Register the plugin in a Filament panel

[](#register-the-plugin-in-a-filament-panel)

```
use Chuimi\FilamentImpersonation\Filament\ImpersonationPlugin;

$panel->plugin(ImpersonationPlugin::make());
```

Once registered, the impersonation banner is shown automatically at the bottom of the panel while any impersonation session is active.

### Add the action to a resource or page

[](#add-the-action-to-a-resource-or-page)

```
use Chuimi\FilamentImpersonation\Filament\Actions\ImpersonateAction;

->actions([
    ImpersonateAction::make(),
])
```

The action is hidden automatically when the current user cannot impersonate the record. It must be added manually to the resources or pages where impersonation should be available.

### Enrich activity logs with impersonation context (opt-in)

[](#enrich-activity-logs-with-impersonation-context-opt-in)

Apply the trait to any Eloquent model that uses `spatie/laravel-activitylog` and should include impersonation context in its activity entries:

```
use Chuimi\FilamentImpersonation\Concerns\HasImpersonationActivityContext;
use Spatie\Activitylog\Traits\LogsActivity;

class SomeAuditableModel extends Model
{
    use LogsActivity;
    use HasImpersonationActivityContext;
}
```

This trait is opt-in and must be added manually per model. The package does not apply impersonation context globally to all activity logs.

Security notes
--------------

[](#security-notes)

- `impersonation.started` is mandatory and recorded before the user switch. If it cannot be written, impersonation does not start.
- Manual logout during impersonation does not restore the original operator.
- The stop route uses `POST` with CSRF protection via the `web` middleware stack. The banner renders the CSRF token automatically.

Full details in [docs/SECURITY.md](docs/SECURITY.md).

Documentation
-------------

[](#documentation)

DocumentDescription[Integration guide](docs/INTEGRATION.md)Installation, plugin registration, authorization, redirects, audit trait, multi-guard[Security guide](docs/SECURITY.md)Security model, audit events, CSRF, known risks, design decisions, audit queries for administrators[Architecture](docs/ARCHITECTURE.md)Design decisions, session payload, activity log events, internal flow[Architecture map](docs/ARCHITECTURE_MAP.md)Component overview and sequence diagramsLicense
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance88

Actively maintained with recent releases

Popularity10

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

2

Last Release

63d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/284569597?v=4)[CHUIMI IT](/maintainers/it-chuimi)[@it-chuimi](https://github.com/it-chuimi)

---

Top Contributors

[![it-chuimi](https://avatars.githubusercontent.com/u/284569597?v=4)](https://github.com/it-chuimi "it-chuimi (18 commits)")

---

Tags

spatielaravelimpersonationAuditfilamentadmin-panelactivityloguser-impersonation

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/chuimi-filament-impersonation/health.svg)

```
[![Health](https://phpackages.com/badges/chuimi-filament-impersonation/health.svg)](https://phpackages.com/packages/chuimi-filament-impersonation)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77922.3M186](/packages/laravel-mcp)[api-platform/laravel

API Platform support for Laravel

58174.6k17](/packages/api-platform-laravel)[mradder/filament-logger

Audit logging, activity tracking, exports, alerts, and dashboards for Filament admin panels.

2318.8k](/packages/mradder-filament-logger)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1235.9k21](/packages/fleetbase-core-api)[laravel/surveyor

Static analysis tool for Laravel applications.

86121.4k14](/packages/laravel-surveyor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
