JFIFxxC      C  " }!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz w!1AQaq"2B #3Rbrlaravel-impersonate/composer.json000064400000002244150364332260013246 0ustar00{ "name": "lab404/laravel-impersonate", "description": "Laravel Impersonate is a plugin that allows to you to authenticate as your users.", "type": "library", "keywords": [ "laravel", "package", "plugin", "impersonate", "impersonation", "user", "auth", "laravel-package", "laravel-plugin" ], "require": { "php": "^7.2 | ^8.0", "laravel/framework": "^6.0 | ^7.0 | ^8.0 | ^9.0 | ^10.0" }, "require-dev": { "phpunit/phpunit": "^7.5 | ^8.0 | ^9.0 | ^10.0", "mockery/mockery": "^1.3.3", "orchestra/testbench": "^4.0 | ^5.0 | ^6.0 | ^7.0 | ^8.0", "orchestra/database": "^4.0 | ^5.0 | ^6.0 | ^7.0 | ^8.0" }, "license": "MIT", "authors": [ { "name": "Marceau Casals", "email": "marceau@casals.fr" } ], "autoload": { "psr-4": { "Lab404\\Impersonate\\": "src/" }, "files": [ "src/helpers.php" ] }, "autoload-dev": { "psr-4": { "Lab404\\Tests\\": "tests/" } }, "extra": { "laravel": { "providers": [ "Lab404\\Impersonate\\ImpersonateServiceProvider" ] } }, "minimum-stability": "dev", "prefer-stable": true } laravel-impersonate/migrations/2020_10_03_233352_create_other_users_table.php000064400000003736150364332260022542 0ustar00increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->boolean('is_admin')->default(0)->index(); $table->boolean('can_be_impersonated')->default(1)->index(); $table->rememberToken(); $table->timestamps(); }); DB::table('other_users')->insert([ [ 'name' => 'OtherAdmin', 'email' => 'otheradmin@test.rocks', 'password' => bcrypt('password'), 'is_admin' => 1, 'can_be_impersonated' => 1, 'created_at' => Carbon::now()->toDateTimeString(), ], [ 'name' => 'OtherUser', 'email' => 'otheruser@test.rocks', 'password' => bcrypt('password'), 'is_admin' => 0, 'can_be_impersonated' => 1, 'created_at' => Carbon::now()->toDateTimeString(), ], [ 'name' => 'OtherSuperAdmin', 'email' => 'othersuperadmin@test.rocks', 'password' => bcrypt('password'), 'is_admin' => 1, 'can_be_impersonated' => 0, 'created_at' => Carbon::now()->toDateTimeString(), ], ]); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('other_users'); } } laravel-impersonate/migrations/2017_02_11_000000_create_users_table.php000064400000003651150364332260021321 0ustar00increments('id'); $table->string('name'); $table->string('email')->unique(); $table->string('password'); $table->boolean('is_admin')->default(0)->index(); $table->boolean('can_be_impersonated')->default(1)->index(); $table->rememberToken(); $table->timestamps(); }); DB::table('users')->insert([ [ 'name' => 'Admin', 'email' => 'admin@test.rocks', 'password' => bcrypt('password'), 'is_admin' => 1, 'can_be_impersonated' => 1, 'created_at' => Carbon::now()->toDateTimeString(), ], [ 'name' => 'User', 'email' => 'user@test.rocks', 'password' => bcrypt('password'), 'is_admin' => 0, 'can_be_impersonated' => 1, 'created_at' => Carbon::now()->toDateTimeString(), ], [ 'name' => 'SuperAdmin', 'email' => 'superadmin@test.rocks', 'password' => bcrypt('password'), 'is_admin' => 1, 'can_be_impersonated' => 0, 'created_at' => Carbon::now()->toDateTimeString(), ], ]); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('users'); } } laravel-impersonate/src/Exceptions/MissingUserProvider.php000064400000000510150364332260020122 0ustar00take($this, $user, $guardName); } /** * Check if the current user is impersonated. * * @param void * @return bool */ public function isImpersonated() { return app(ImpersonateManager::class)->isImpersonating(); } /** * Leave the current impersonation. * * @param void * @return bool */ public function leaveImpersonation() { if ($this->isImpersonated()) { return app(ImpersonateManager::class)->leave(); } } } laravel-impersonate/src/Controllers/ImpersonateController.php000064400000004272150364332260020667 0ustar00manager = app()->make(ImpersonateManager::class); $guard = $this->manager->getDefaultSessionGuard(); $this->middleware('auth:' . $guard)->only('take'); } /** * @param int $id * @param string|null $guardName * @return RedirectResponse * @throws \Exception */ public function take(Request $request, $id, $guardName = null) { $guardName = $guardName ?? $this->manager->getDefaultSessionGuard(); // Cannot impersonate yourself if ($id == $request->user()->getAuthIdentifier() && ($this->manager->getCurrentAuthGuardName() == $guardName)) { abort(403); } // Cannot impersonate again if you're already impersonate a user if ($this->manager->isImpersonating()) { abort(403); } if (!$request->user()->canImpersonate()) { abort(403); } $userToImpersonate = $this->manager->findUserById($id, $guardName); if ($userToImpersonate->canBeImpersonated()) { if ($this->manager->take($request->user(), $userToImpersonate, $guardName)) { $takeRedirect = $this->manager->getTakeRedirectTo(); if ($takeRedirect !== 'back') { return redirect()->to($takeRedirect); } } } return redirect()->back(); } /** * @return RedirectResponse */ public function leave() { if (!$this->manager->isImpersonating()) { abort(403); } $this->manager->leave(); $leaveRedirect = $this->manager->getLeaveRedirectTo(); if ($leaveRedirect !== 'back') { return redirect()->to($leaveRedirect); } return redirect()->back(); } } laravel-impersonate/src/Impersonate.php000064400000000555150364332260014315 0ustar00impersonator = $impersonator; $this->impersonated = $impersonated; } } laravel-impersonate/src/Events/TakeImpersonation.php000064400000001601150364332260016720 0ustar00impersonator = $impersonator; $this->impersonated = $impersonated; } } laravel-impersonate/src/ImpersonateServiceProvider.php000064400000012313150364332260017344 0ustar00mergeConfig(); $this->app->bind(ImpersonateManager::class, ImpersonateManager::class); $this->app->singleton(ImpersonateManager::class, function ($app) { return new ImpersonateManager($app); }); $this->app->alias(ImpersonateManager::class, 'impersonate'); $this->registerRoutesMacro(); $this->registerBladeDirectives(); $this->registerMiddleware(); $this->registerAuthDriver(); } /** * Bootstrap the application events. * * @return void */ public function boot() { $this->publishConfig(); // We want to remove data from storage on real login and logout Event::listen(Login::class, function ($event) { app('impersonate')->clear(); }); Event::listen(Logout::class, function ($event) { app('impersonate')->clear(); }); } /** * Register plugin blade directives. * * @param void * @return void */ protected function registerBladeDirectives() { $this->app->afterResolving('blade.compiler', function (BladeCompiler $bladeCompiler) { $bladeCompiler->directive('impersonating', function ($guard = null) { return ""; }); $bladeCompiler->directive('endImpersonating', function () { return ''; }); $bladeCompiler->directive('canImpersonate', function ($guard = null) { return ""; }); $bladeCompiler->directive('endCanImpersonate', function () { return ''; }); $bladeCompiler->directive('canBeImpersonated', function ($expression) { $args = preg_split("/,(\s+)?/", $expression); $guard = $args[1] ?? null; return ""; }); $bladeCompiler->directive('endCanBeImpersonated', function () { return ''; }); }); } /** * Register routes macro. * * @param void * @return void */ protected function registerRoutesMacro() { $router = $this->app['router']; $router->macro('impersonate', function () use ($router) { $router->get('/impersonate/take/{id}/{guardName?}', '\Lab404\Impersonate\Controllers\ImpersonateController@take')->name('impersonate'); $router->get('/impersonate/leave', '\Lab404\Impersonate\Controllers\ImpersonateController@leave')->name('impersonate.leave'); }); } /** * @param void * @return void */ protected function registerAuthDriver() { /** @var AuthManager $auth */ $auth = $this->app['auth']; $auth->extend('session', function (Application $app, $name, array $config) use ($auth) { $provider = $auth->createUserProvider($config['provider']); $guard = new SessionGuard($name, $provider, $app['session.store']); if (method_exists($guard, 'setCookieJar')) { $guard->setCookieJar($app['cookie']); } if (method_exists($guard, 'setDispatcher')) { $guard->setDispatcher($app['events']); } if (method_exists($guard, 'setRequest')) { $guard->setRequest($app->refresh('request', $guard, 'setRequest')); } return $guard; }); } /** * Register plugin middleware. * * @param void * @return void */ public function registerMiddleware() { $this->app['router']->aliasMiddleware('impersonate.protect', ProtectFromImpersonation::class); } /** * Merge config file. * * @param void * @return void */ protected function mergeConfig() { $configPath = __DIR__ . '/../config/' . $this->configName . '.php'; $this->mergeConfigFrom($configPath, $this->configName); } /** * Publish config file. * * @param void * @return void */ protected function publishConfig() { $configPath = __DIR__ . '/../config/' . $this->configName . '.php'; $this->publishes([$configPath => config_path($this->configName . '.php')], 'impersonate'); } } laravel-impersonate/src/Services/ImpersonateManager.php000064400000015771150364332260017401 0ustar00app = $app; } /** * @param int $id * @return \Illuminate\Contracts\Auth\Authenticatable * @throws MissingUserProvider * @throws InvalidUserProvider * @throws ModelNotFoundException */ public function findUserById($id, $guardName = null) { if (empty($guardName)) { $guardName = $this->app['config']->get('auth.default.guard', 'web'); } $providerName = $this->app['config']->get("auth.guards.$guardName.provider"); if (empty($providerName)) { throw new MissingUserProvider($guardName); } try { /** @var UserProvider $userProvider */ $userProvider = $this->app['auth']->createUserProvider($providerName); } catch (\InvalidArgumentException $e) { throw new InvalidUserProvider($guardName); } if (!($modelInstance = $userProvider->retrieveById($id))) { $model = $this->app['config']->get("auth.providers.$providerName.model"); throw (new ModelNotFoundException())->setModel( $model, $id ); } return $modelInstance; } public function isImpersonating(): bool { return session()->has($this->getSessionKey()); } /** * @return int|null */ public function getImpersonatorId() { return session($this->getSessionKey(), null); } /** * @return \Illuminate\Contracts\Auth\Authenticatable */ public function getImpersonator() { $id = session($this->getSessionKey(), null); return is_null($id) ? null : $this->findUserById($id, $this->getImpersonatorGuardName()); } /** * @return string|null */ public function getImpersonatorGuardName() { return session($this->getSessionGuard(), null); } /** * @return string|null */ public function getImpersonatorGuardUsingName() { return session($this->getSessionGuardUsing(), null); } /** * @param \Illuminate\Contracts\Auth\Authenticatable $from * @param \Illuminate\Contracts\Auth\Authenticatable $to * @param string|null $guardName * @return bool */ public function take($from, $to, $guardName = null) { $this->saveAuthCookieInSession(); try { $currentGuard = $this->getCurrentAuthGuardName(); session()->put($this->getSessionKey(), $from->getAuthIdentifier()); session()->put($this->getSessionGuard(), $currentGuard); session()->put($this->getSessionGuardUsing(), $guardName); $this->app['auth']->guard($currentGuard)->quietLogout(); $this->app['auth']->guard($guardName)->quietLogin($to); } catch (\Exception $e) { unset($e); return false; } $this->app['events']->dispatch(new TakeImpersonation($from, $to)); return true; } public function leave(): bool { try { $impersonated = $this->app['auth']->guard($this->getImpersonatorGuardUsingName())->user(); $impersonator = $this->findUserById($this->getImpersonatorId(), $this->getImpersonatorGuardName()); $this->app['auth']->guard($this->getCurrentAuthGuardName())->quietLogout(); $this->app['auth']->guard($this->getImpersonatorGuardName())->quietLogin($impersonator); $this->extractAuthCookieFromSession(); $this->clear(); } catch (\Exception $e) { unset($e); return false; } $this->app['events']->dispatch(new LeaveImpersonation($impersonator, $impersonated)); return true; } public function clear() { session()->forget($this->getSessionKey()); session()->forget($this->getSessionGuard()); session()->forget($this->getSessionGuardUsing()); } public function getSessionKey(): string { return config('laravel-impersonate.session_key'); } public function getSessionGuard(): string { return config('laravel-impersonate.session_guard'); } public function getSessionGuardUsing(): string { return config('laravel-impersonate.session_guard_using'); } public function getDefaultSessionGuard(): string { return config('laravel-impersonate.default_impersonator_guard'); } public function getTakeRedirectTo(): string { try { $uri = route(config('laravel-impersonate.take_redirect_to')); } catch (\InvalidArgumentException $e) { $uri = config('laravel-impersonate.take_redirect_to'); } return $uri; } public function getLeaveRedirectTo(): string { try { $uri = route(config('laravel-impersonate.leave_redirect_to')); } catch (\InvalidArgumentException $e) { $uri = config('laravel-impersonate.leave_redirect_to'); } return $uri; } /** * @return array|null */ public function getCurrentAuthGuardName() { $guards = array_keys(config('auth.guards')); foreach ($guards as $guard) { if ($this->app['auth']->guard($guard)->check()) { return $guard; } } return null; } protected function saveAuthCookieInSession(): void { $cookie = $this->findByKeyInArray($this->app['request']->cookies->all(), static::REMEMBER_PREFIX); $key = $cookie->keys()->first(); $val = $cookie->values()->first(); if (!$key || !$val) { return; } session()->put(static::REMEMBER_PREFIX, [ $key, $val, ]); } protected function extractAuthCookieFromSession(): void { if (!$session = $this->findByKeyInArray(session()->all(), static::REMEMBER_PREFIX)->first()) { return; } $this->app['cookie']->queue($session[0], $session[1]); session()->forget($session); } /** * @param array $values * @param string $search * @return \Illuminate\Support\Collection */ protected function findByKeyInArray(array $values, string $search) { return collect($values ?? session()->all()) ->filter(function ($val, $key) use ($search) { return strpos($key, $search) !== false; }); } } laravel-impersonate/src/helpers.php000064400000002562150364332260013471 0ustar00getCurrentAuthGuardName(); return app('auth')->guard($guard)->check() && app('auth')->guard($guard)->user()->canImpersonate(); } } if (! function_exists('can_be_impersonated')) { /** * Check whether the specified user can be impersonated. * * @param Authenticatable $user * @param string|null $guard * @return bool */ function can_be_impersonated(Authenticatable $user, string $guard = null): bool { $guard = $guard ?? app('impersonate')->getCurrentAuthGuardName(); return app('auth')->guard($guard)->check() && app('auth')->guard($guard)->user()->isNot($user) && $user->canBeImpersonated(); } } if (! function_exists('is_impersonating')) { /** * Check whether the current user is being impersonated. * * @param string|null $guard * @return bool */ function is_impersonating(string $guard = null): bool { $guard = $guard ?? app('impersonate')->getCurrentAuthGuardName(); return app('auth')->guard($guard)->check() && app('auth')->guard($guard)->user()->isImpersonated(); } } laravel-impersonate/src/Middleware/ProtectFromImpersonation.php000064400000001161150364332260021112 0ustar00make(ImpersonateManager::class); if ($impersonate_manager->isImpersonating()) { return Redirect::back(); } return $next($request); } } laravel-impersonate/src/Guard/SessionGuard.php000064400000001516150364332260015475 0ustar00updateSession($user->getAuthIdentifier()); $this->setUser($user); } /** * Logout the user without updating remember_token * and without firing the Logout event. * * @param void * @return void */ public function quietLogout() { $this->clearUserDataFromStorage(); $this->user = null; $this->loggedOut = true; } } laravel-impersonate/readme.md000064400000015650150364332260012310 0ustar00# Laravel Impersonate [![Build Status](https://travis-ci.org/404labfr/laravel-impersonate.svg?branch=master)](https://travis-ci.org/404labfr/laravel-impersonate) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/404labfr/laravel-impersonate/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/404labfr/laravel-impersonate/?branch=master) **Laravel Impersonate** makes it easy to **authenticate as your users**. Add a simple **trait** to your **user model** and impersonate as one of your users in one click. - [Requirements](#requirements) - [Installation](#installation) - [Simple usage](#simple-usage) - [Using the built-in controller](#using-the-built-in-controller) - [Advanced Usage](#advanced-usage) - [Defining impersonation authorization](#defining-impersonation-authorization) - [Using your own strategy](#using-your-own-strategy) - [Middleware](#middleware) - [Events](#events) - [Configuration](#configuration) - [Blade](#blade) - [Tests](#tests) - [Contributors](#contributors) - [Why Not Just Use loginAsId()?](#rationale) ## Requirements - Laravel 6.x to 9.x - PHP >= 7.2 or >= 8.0 ### Laravel support | Version | Release | |:-------------:|:-------------:| | 6.x to 10.x | 1.7 | | 6.x, 7.x | 1.6 | | 5.8 | 1.5 | | 5.7, 5.6 | 1.2 | | 5.5, 5.4 | 1.1 | ## Installation - Require it with Composer: ```bash composer require lab404/laravel-impersonate ``` - Add the service provider at the end of your `config/app.php`: ```php 'providers' => [ // ... Lab404\Impersonate\ImpersonateServiceProvider::class, ], ``` - Add the trait `Lab404\Impersonate\Models\Impersonate` to your **User** model. ## Simple usage Impersonate a user: ```php Auth::user()->impersonate($other_user); // You're now logged as the $other_user ``` Leave impersonation: ```php Auth::user()->leaveImpersonation(); // You're now logged as your original user. ``` ### Using the built-in controller In your routes file, under web middleware, you must call the `impersonate` route macro. ```php Route::impersonate(); ``` Alternatively, you can execute this macro with your `RouteServiceProvider`. ```php namespace App\Providers; class RouteServiceProvider extends ServiceProvider { public function map() { Route::middleware('web')->group(function (Router $router) { $router->impersonate(); }); } } ``` ```php // Where $id is the ID of the user you want impersonate route('impersonate', $id) // Or in case of multi guards, you should also add `guardName` (defaults to `web`) route('impersonate', ['id' => $id, 'guardName' => 'admin']) // Generate an URL to leave current impersonation route('impersonate.leave') ``` ## Advanced Usage ### Defining impersonation authorization By default all users can **impersonate** an user. You need to add the method `canImpersonate()` to your user model: ```php /** * @return bool */ public function canImpersonate() { // For example return $this->is_admin == 1; } ``` By default all users can **be impersonated**. You need to add the method `canBeImpersonated()` to your user model to extend this behavior: ```php /** * @return bool */ public function canBeImpersonated() { // For example return $this->can_be_impersonated == 1; } ``` ### Using your own strategy - Getting the manager: ```php // With the app helper app('impersonate') // Dependency Injection public function impersonate(ImpersonateManager $manager, $user_id) { /* ... */ } ``` - Working with the manager: ```php $manager = app('impersonate'); // Find an user by its ID $manager->findUserById($id); // TRUE if your are impersonating an user. $manager->isImpersonating(); // Impersonate an user. Pass the original user and the user you want to impersonate $manager->take($from, $to); // Leave current impersonation $manager->leave(); // Get the impersonator ID $manager->getImpersonatorId(); ``` ### Middleware **Protect From Impersonation** You can use the middleware `impersonate.protect` to protect your routes against user impersonation. This middleware can be useful when you want to protect specific pages like users subscriptions, users credit cards, ... ```php Router::get('/my-credit-card', function() { echo "Can't be accessed by an impersonator"; })->middleware('impersonate.protect'); ``` ### Events There are two events available that can be used to improve your workflow: - `TakeImpersonation` is fired when an impersonation is taken. - `LeaveImpersonation` is fired when an impersonation is leaved. Each events returns two properties `$event->impersonator` and `$event->impersonated` containing User model instance. ## Configuration The package comes with a configuration file. Publish it with the following command: ```bash php artisan vendor:publish --tag=impersonate ``` Available options: ```php // The session key used to store the original user id. 'session_key' => 'impersonated_by', // Where to redirect after taking an impersonation. // Only used in the built-in controller. // You can use: an URI, the keyword back (to redirect back) or a route name 'take_redirect_to' => '/', // Where to redirect after leaving an impersonation. // Only used in the built-in controller. // You can use: an URI, the keyword back (to redirect back) or a route name 'leave_redirect_to' => '/' ``` ## Blade There are three Blade directives available. ### When the user can impersonate ```blade @canImpersonate($guard = null) Impersonate this user @endCanImpersonate ``` ### When the user can be impersonated This comes in handy when you have a user list and want to show an "Impersonate" button next to all the users. But you don\'t want that button next to the current authenticated user neither to that users which should not be able to impersonated according your implementation of `canBeImpersonated()` . ```blade @canBeImpersonated($user, $guard = null) Impersonate this user @endCanBeImpersonated ``` ### When the user is impersonated ```blade @impersonating($guard = null) Leave impersonation @endImpersonating ``` ## Tests ```bash vendor/bin/phpunit ``` ## Contributors - This package was created by [MarceauKa](https://github.com/MarceauKa) and [tghpow](https://github.com/tghpow). Many thanks to all of our [contributors](https://github.com/404labfr/laravel-impersonate/graphs/contributors). ## Rationale ### Why not just use `loginAsId()`? This package adds broader functionality, including Blade directives to allow you to override analytics and other tracking events when impersonating, fire events based on impersonation status, and more. Brief discussion at [issues/5](https://github.com/404labfr/laravel-impersonate/issues/5) ## Licence MIT laravel-impersonate/changelog.md000064400000010730150364332260012774 0ustar00# Laravel Impersonate Changelog ## 1.7.4 - Laravel 10.x support (thanks to [freekmurze](Freek Van der Herten]), [#175](https://github.com/404labfr/laravel-impersonate/pull/175)) ## 1.7.3 - Laravel 9.x support (thanks to [freekmurze](Freek Van der Herten]), [#149](https://github.com/404labfr/laravel-impersonate/pull/149)) ## 1.7.2 ### Added - Supports for PHP 8.0 (thanks to [pascalbaljet](https://github.com/pascalbaljet), [#121](https://github.com/404labfr/laravel-impersonate/pull/121)) ### Fixed - getImpersonator() when working with multiple guards (thanks to [carsso](https://github.com/carsso)), [#120](https://github.com/404labfr/laravel-impersonate/pull/120)) - Can't leave impersonation when multi-guard is used (thanks to [ctf0](https://github.com/ctf0), [#116](https://github.com/404labfr/laravel-impersonate/pull/117)) ### Changed - Allow guard name in blade directives (thanks to [ctf0](https://github.com/ctf0), [#115](https://github.com/404labfr/laravel-impersonate/pull/117)) - Documentation about multi-guard usage (thanks to [ctf0](https://github.com/ctf0), [#117](https://github.com/404labfr/laravel-impersonate/pull/117)) ### Removed - composer.lock ## 1.7.1 ### Added - Laravel 8.x support ## 1.7.0 ### Added - `ImpersonateManager@findUserById` will now throw a `MissingUserProvider` exception when guard has no user provider [baa722b](https://github.com/404labfr/laravel-impersonate/commit/baa722b1bde0aefd9efbd9454c699b7894ddc49b) - `ImpersonateManager@findUserById` will now throw a `InvalidUserProvider` exception when guard has an invalid user provider [baa722b](https://github.com/404labfr/laravel-impersonate/commit/baa722b1bde0aefd9efbd9454c699b7894ddc49b) ### Changed - Helper `can_be_impersonated` now use model `getAuthIdentifier()` instead of hardcoded `id` column [#105](https://github.com/404labfr/laravel-impersonate/pull/105) - Git attributes [#108](https://github.com/404labfr/laravel-impersonate/pull/108) ## 1.6.0 ### Added - Laravel 7.x support ### Removed - Laravel 5.x support ## 1.5.1 ### Changed - Use `Illuminate\Contracts\Auth\Authenticatable@getAuthIdentifier` instead of `Illuminate\Database\Eloquent\Model@getKey` [#96](https://github.com/404labfr/laravel-impersonate/pull/96) - PHPDoc updated ## 1.5.0 ### Changed - Events uses `Illuminate\Contracts\Auth\Authenticatable` instead of `Illuminate\Database\Eloquent\Model` [#92](https://github.com/404labfr/laravel-impersonate/pull/92) - PHPDoc and return values for `ImpersonateManager` ### Fixed - Security issue for `symfony/http-foundation` ([CVE-2019-18888](https://github.com/advisories/GHSA-xhh6-956q-4q69)) ## 1.4.3 ### Fixed - `can_impersonate()` helper - Tests for Blade directives ## 1.4.2 ### Added - `is_impersonating()`, `can_impersonate()` and `can_be_impersonated()` helpers ### Changed - Blade directives now use helpers ## 1.4.1 ### Fixed - Laravel 6.0 dependencies compatibility - dump() in ImpersonateManager.php ## 1.4.0 ### Added - Allows impersonation through multiple guards ([Pull 58](https://github.com/404labfr/laravel-impersonate/pull/58)) - Added the public method `getImpersonator` to `ImpersonateManager` ([Pull 69](https://github.com/404labfr/laravel-impersonate/pull/69)) ### Changed - Laravel 6.0 compatibility (min version is 5.8) ### Fixed - The user `remember_token` is now preserved ([Pull 71](https://github.com/404labfr/laravel-impersonate/pull/71)) ## 1.3.0 (2019-02-28) ### Changed - Laravel 5.8 compatibility (min version) ## 1.2.3 (2018-09-03) ### Changed - Documentation - Use `getSessionKey()` in `take()` method ## 1.2.2 (2018-01-19) ### Changed - Register Blade directives after resolving ### Fixed - Blade directives documentation ## 1.2.1 (2017-09-03) ### Changed - PHP version requirement - Laravel version requirement ## 1.2.0 (2017-07-28) ### Added - Laravel 5.5 compatibility - Package auto-discovery ## 1.1.0 (2017-03-05) ### Added - Custom Session guard driver based on the original Session Guard ([c76bb96](https://github.com/404labfr/laravel-impersonate/commit/c76bb96da9ca53b70fd3ce5d063722076ffcbcb4)) ### Changed - The Auth events `login`, `authenticated` and `logout` are not fired anymore when taking or leaving impersonation ### Fixed - The user remember token is not touched when taking and leaving impersonation ([#11](https://github.com/404labfr/laravel-impersonate/issues/11)) ## 1.0.11 (2017-03-05) ### Added - New blade directive `canBeImpersonated` ([#12](https://github.com/404labfr/laravel-impersonate/issues/12)) laravel-impersonate/config/laravel-impersonate.php000064400000001645150364332260016460 0ustar00 'impersonated_by', /** * The session key used to stored the original user guard. */ 'session_guard' => 'impersonator_guard', /** * The session key used to stored what guard is impersonator using. */ 'session_guard_using' => 'impersonator_guard_using', /** * The default impersonator guard used. */ 'default_impersonator_guard' => 'web', /** * The URI to redirect after taking an impersonation. * * Only used in the built-in controller. * * Use 'back' to redirect to the previous page */ 'take_redirect_to' => '/', /** * The URI to redirect after leaving an impersonation. * * Only used in the built-in controller. * Use 'back' to redirect to the previous page */ 'leave_redirect_to' => '/', ];