Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Impersonation Bundle

Impersonation Bundle Laravel Package

nti/impersonation-bundle

A PHP package for safely impersonating users in your application. Administrators can switch into another account to troubleshoot or verify permissions, then return to their own session. Integrates with existing authentication and supports controlled, auditable impersonation.

View on GitHub
Deep Wiki
Context7

Symfony2 ImpersonationBundle.

Frequently asked questions about Impersonation Bundle
Can I use nti/impersonation-bundle in a Laravel application?
No. nti/impersonation-bundle is a Symfony2 bundle that targets Symfony's kernel, DI container, firewall listener, and TokenStorage/SecurityContext; Laravel has no equivalent bundle contract. The only shared surface is Composer and PHP, so the out-of-box Laravel fit is effectively zero. For Laravel, use a Laravel-native package or a small in-house implementation instead.
How do I install and configure nti/impersonation-bundle?
It is installed with Composer as a Symfony bundle and wired into a Symfony kernel, security firewall, and routing configuration. There is no Laravel service provider, config publish command, or middleware, so the normal Laravel installation flow does not apply. Before any use, inspect composer.json for exact Symfony and PHP constraints and confirm the bundle boots on your PHP version.
Does nti/impersonation-bundle support Laravel 10 or Laravel 11?
No Laravel version support is provided because this is not a Laravel package. It does not ship an Illuminate service provider, Laravel middleware, gates, or Blade helpers. Laravel 10 and 11 applications should evaluate lab404/laravel-impersonate or build impersonation on native Auth and Gate primitives.
What is a good Laravel alternative to nti/impersonation-bundle?
A commonly used option is lab404/laravel-impersonate, but verify its release cadence and security advisory history before adopting it. For tight control, implement impersonation with Auth::login($targetUser), a session key for the impersonator ID, a canImpersonate gate or policy, middleware to block nested impersonation, and an audit event. Both options avoid coupling a Laravel app to a Symfony bundle.
How do I implement user impersonation in Laravel without a package?
Store the original admin ID in the session, call Auth::login($targetUser) after a canImpersonate authorization check, and log an audit event with actor, target, timestamp, and source IP. Add middleware that blocks chained impersonation while the impersonation session key is present. To exit, log the stop event, restore the original admin session, and call Auth::login($adminUser) or regenerate the session safely. The technical evaluation estimates this at roughly 50 to 150 lines of application code.
Is nti/impersonation-bundle maintained and safe for production?
Treat it as high risk. The last release was 2019-04-02, it has 1 star and 0 dependents, and there is no apparent security disclosure path or visible CVE history. Impersonation is an authentication-bypass primitive, so missing tests and abandoned maintenance are especially dangerous; do not put it into production without a full security review.
What Symfony and PHP versions does nti/impersonation-bundle require?
The exact constraints are unverified from the provided material and must be read from composer.json. The evaluation describes it as a Symfony2 bundle, and Symfony 2.8 security support ended in November 2018, so adoption likely means running an EOL framework. It is also unknown whether it boots on PHP 8.2 or later.
Does nti/impersonation-bundle write an audit record for impersonation start and stop?
The overview says the bundle exposes event hooks so you can audit or react to impersonation start and stop. It does not confirm that the bundle itself writes an immutable record containing actor, target, timestamp, and source IP. For compliance, verify the source and add your own listener or logging if those fields are not guaranteed on both enter and exit.
Does nti/impersonation-bundle prevent nested impersonation and restore the original session?
The package description says the original admin session is preserved and that session handling is configurable, so you can switch back without logging in again. However, the evaluation flags open questions about nested or chained impersonation and whether exit fully restores the original session token or leaves a session-fixation risk. Inspect the listener and test enter, exit, and re-enter flows before trusting it.
Is nti/impersonation-bundle better than Symfony's built-in switch_user?
No. Symfony's SecurityBundle has shipped a first-class switch_user firewall option, including ROLE_ALLOWED_TO_SWITCH, the _switch_user query parameter, and exit via _switch_user=_exit, since the 2.x era. A third-party bundle wrapping the same concept adds dependency and maintenance risk with little benefit. For Laravel, neither option applies directly; use Laravel-native primitives.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console