{"id":13733613,"url":"https://github.com/stechstudio/filament-impersonate","last_synced_at":"2026-02-22T18:09:41.604Z","repository":{"id":41311374,"uuid":"352468212","full_name":"stechstudio/filament-impersonate","owner":"stechstudio","description":"Filament plugin that makes it easy to impersonate your users","archived":false,"fork":false,"pushed_at":"2026-02-12T19:22:10.000Z","size":130,"stargazers_count":369,"open_issues_count":1,"forks_count":97,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-02-13T01:23:28.230Z","etag":null,"topics":["filament","filamentphp","impersonate","impersonation","laravel","plugin"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stechstudio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-03-29T00:10:34.000Z","updated_at":"2026-02-12T19:10:51.000Z","dependencies_parsed_at":"2024-02-03T02:43:42.728Z","dependency_job_id":"c83c0f42-5fe0-4304-90b4-a3f6879d5573","html_url":"https://github.com/stechstudio/filament-impersonate","commit_stats":{"total_commits":38,"total_committers":14,"mean_commits":"2.7142857142857144","dds":"0.42105263157894735","last_synced_commit":"75121fed63883f037c7c3855fbfc4ee609d17f38"},"previous_names":[],"tags_count":56,"template":false,"template_full_name":null,"purl":"pkg:github/stechstudio/filament-impersonate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Ffilament-impersonate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Ffilament-impersonate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Ffilament-impersonate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Ffilament-impersonate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stechstudio","download_url":"https://codeload.github.com/stechstudio/filament-impersonate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stechstudio%2Ffilament-impersonate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29721255,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T15:10:41.462Z","status":"ssl_error","status_checked_at":"2026-02-22T15:10:04.636Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["filament","filamentphp","impersonate","impersonation","laravel","plugin"],"created_at":"2024-08-03T03:00:46.284Z","updated_at":"2026-02-22T18:09:41.567Z","avatar_url":"https://github.com/stechstudio.png","language":"PHP","funding_links":[],"categories":["MISC","Login"],"sub_categories":[],"readme":"# Filament Impersonate\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/stechstudio/filament-impersonate.svg?style=flat-square)](https://packagist.org/packages/stechstudio/filament-impersonate)\n[![Total Downloads](https://img.shields.io/packagist/dt/stechstudio/filament-impersonate.svg?style=flat-square)](https://packagist.org/packages/stechstudio/filament-impersonate)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n\nThis is a plugin for [Filament](https://filamentadmin.com/) that makes it easy to impersonate your users. \n\n## Installation\n\nYou know the drill:\n\n```bash\ncomposer require stechstudio/filament-impersonate\n```\n\n## Quickstart\n\n### 1. Add table action\n\nFirst open the resource where you want the impersonate action to appear. This is generally going to be your `UserResource` class.\n\nGo down to the `table` method. After defining the table columns, you want to add `Impersonate` as a new action for the table via `actions` method. Your class should look like this:\n\n```php\nnamespace App\\Filament\\Resources;\n\nuse Filament\\Resources\\Resource;\nuse STS\\FilamentImpersonate\\Actions\\Impersonate;\n\nclass UserResource extends Resource {\n    public static function table(Table $table)\n    {\n        return $table\n            -\u003ecolumns([\n                // ...\n            ])\n            -\u003eactions([\n                Impersonate::make(), // \u003c--- \n            ]);\n    }\n```\n\nYou can also define a `guard` and `redirectTo` for the action:\n\n```php\nImpersonate::make('impersonate')\n    -\u003eguard('another-guard')\n    -\u003eredirectTo(route('some.other.route'));\n```\n    \n### 2. Add the page action\n\nNow open the page where you would want the button to appear, this will commonly be `EditUser`;\n\nGo to the `getActions` method and add the `Impersonate` page action here.\n\n```php\n\u003c?php\nnamespace App\\Filament\\Resources\\UserResource\\Pages;\n\nuse App\\Filament\\Resources\\UserResource;\nuse Filament\\Resources\\Pages\\EditRecord;\nuse STS\\FilamentImpersonate\\Actions\\Impersonate;\n\nclass EditUser extends EditRecord\n{\n    protected static string $resource = UserResource::class;\n\n    protected function getActions(): array\n    {\n        return [\n            Impersonate::make()-\u003erecord($this-\u003egetRecord()) // \u003c--\n        ];\n    }\n}\n```\n\nNote: you must pass the record in as seen in this example!\n\n### 3. Add the banner to your non-filament blade layout(s)\n\nIf your app is entirely contained within Filament, you're already done! The banner gets registered automatically.\n\nHowever, if you impersonate a user and then visit non-Filament pages or layouts, you'll be stuck. In those cases, you'll need to display a notice in your app whenever you are impersonating another user. \n\nYou can do that by adding `\u003cx-impersonate::banner/\u003e` to your master layout(s) before the closing `\u003c/body\u003e` tag.\n\n### 4. Profit!\n\nThat's it. You should now see an action icon next to each user in your Filament `UserResource` list:\n\n\u003cimg width=\"1164\" alt=\"CleanShot 2022-01-03 at 14 10 36@2x\" src=\"https://user-images.githubusercontent.com/203749/147969981-01d18612-bc71-4503-89f6-a8e625ba2a5d.png\"\u003e\n\nWhen you click on the impersonate icon you will be logged in as that user, and redirected to your main app. You will see the impersonation banner at the top of the page, with a button to leave and return to Filament:\n\n![banner](https://user-images.githubusercontent.com/203749/112773267-5331b400-9003-11eb-85ae-b54c458fb5aa.png)\n\n\n## Configuration\n\nAll configuration can be managed with ENV variables, no need to publish and edit the config directly. Just check out the [config file](/config/filament-impersonate.php).\n\n## Facade API\n\nYou can use the facade for programmatic impersonation control:\n\n```php\nuse STS\\FilamentImpersonate\\Facades\\Impersonation;\n\nif (Impersonation::isImpersonating()) {\n    Impersonation::leave();\n}\n```\n\n## Authorization\n\nBy default, only Filament admins can impersonate other users. You can control this by adding a `canImpersonate` method to your `FilamentUser` class:\n\n```php\nclass User implements FilamentUser {\n    \n    public function canImpersonate()\n    {\n        return true;\n    }\n    \n}\n```\n\nYou can also control which targets can *be* impersonated. Just add a `canBeImpersonated` method to the user class with whatever logic you need:\n\n```php\nclass User {\n\n    public function canBeImpersonated()\n    {\n        // Let's prevent impersonating other users at our own company\n        return !Str::endsWith($this-\u003eemail, '@mycorp.com');\n    }\n    \n}\n``` \n\n\u003e [!NOTE]\n\u003e As of 4.0, the plugin detects soft-deleted targets and prevents impersonation. You can set `FILAMENT_IMPERSONATE_ALLOW_SOFT_DELETED=true` in your .env to override this behavior.\n\n## Customizing the banner\n\nThe blade component has a few options you can customize. \n\n### Style\n\nThe banner is dark by default, you can set this to light, or auto.\n\n```html\n\u003cx-impersonate::banner style='light'/\u003e\n```\n\n### Display name\n\nThe banner will show the name of the impersonated user, assuming there is a `name` attribute. You can customize this if needed:\n\n```html\n\u003cx-impersonate::banner :display='auth()-\u003euser()-\u003eemail'/\u003e\n```\n\n## Potential Issues and Workarounds\n\n### 403 when a ListUsers widget has `InteractsWithPageTable`\n\n**TL;DR:** Add a guard clause like this to your `UserPolicy::viewAny()` method:\n\n```php\n\u003c?php\n\nuse STS\\FilamentImpersonate\\Facades\\Impersonation;\n\npublic function viewAny(User $user): bool\n{\n    if (Impersonation::isImpersonating()) {\n        return true;\n    }\n\n    // ... Any other checks here\n}\n```\n\nThe core of this problem is that the Livewire components on the page attempt to re-render before the redirect occurs. \n\nThen, even with a -\u003eredirectTo() set, if your policies prevent the impersonated user from accessing the user list that you're impersonating from, Filament attempts to re-render the table widgets, triggering a 403.\n\nThere's not much we can do about this, but checking whether the current user is impersonating already will at least avoid the 403.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstechstudio%2Ffilament-impersonate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstechstudio%2Ffilament-impersonate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstechstudio%2Ffilament-impersonate/lists"}