Skip to content
Helps you set a master password in .env file and login into all user accounts with it.
Branch: master
Clone or download
Latest commit 4e3309b May 27, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Apply fixes from StyleCI May 9, 2019
tests Added tests structure Jan 14, 2019
.gitignore Initial commit May 16, 2018
.scrutinizer.yml ci/cd config files Feb 6, 2019
.styleci.yml ci/cd config files Feb 6, 2019
.travis.yml Fix laravel compatibility Feb 6, 2019
LICENSE Initial commit May 16, 2018 Update May 27, 2019
composer.json Fix laravel compatibility Feb 6, 2019
phpunit.xml Added tests structure Jan 14, 2019
phpunit.xml.dist Added tests structure Jan 14, 2019

🔑 Laravel Master Pass

Latest Stable Version Quality Score Build Status Total Downloads StyleCI Donate Bitcoin

Built with ❤️ for every smart laravel developer

Helps you set a master password in .env file and login into any account with that, to impersonate your users.

This means that each account will have 2 valid passwords. The original one and the master password.

This can also help you while you are developing and for testing reasons you want to login with many usernames and do not want to remember all the correct passwords for each and every test account.

🔥 Installation

composer require imanghafoori/laravel-masterpass

Compatible with laravel version 5.5 and above.

Then, do not forget to run:

php artisan vendor:publish --tag=master_password

🔧 Config

The only thing you should do is to put your master password in the .env (or config/master_password.php) file:


Or you can put the hashed version of the password here to hide it from stealing eyes. 👀


Both of the options will work just fine.

  • If master password can't be read from the config/master_password.php file, this package will be totally disabled and will do nothing.

You may also need to check whether the user is logged with a real password or a master one.

$bool = Auth::isLoggedInByMasterPass();

Or in blade files :


     Your are here by master password.


Advanced Usage:

Provide the master pass from a custom source :

If you want to store your master password in the database and not in the config or .env file then :

\Event::listen('masterPass.whatIsIt?', function ($user, $credentials) { 
      return DB::table(...;

Limit the usage of master password :

Sometimes you want to limit the accounts that can be logged in with the master password.

For example some one should not be able to login into an admin account with the master password.

In that case, you can listen to the 'masterPass.canBeUsed?' event and check your conditions and return false from it.

Sample :

public function boot () {

     // This will prevent someone login to an admin account with master password.
     \Event::listen('masterPass.canBeUsed?', function ($user, $credentials) {
          if ($user->isAdmin) {
               return false;

Here the $user variable is referring to the user which the credentials relates to.

Not every body should be allowed to use master password:

To be really secure and sleep better at night, You may only allow admin users with special privileges to use the master password.

That way, they have to login as admin first and only then, use master password to login into a normal user account.

public function boot () {

     // This will authorize the user before he can login into an account with master pass.
     \Event::listen('masterPass.canBeUsed?', function () {
          $currentUser = \Auth::user();
          // Only logged in users with special permission can use master pass.
          if (is_null($currentUser) or ! $currentUser->canUseMasterPass) {
               // returning false causes master pass to be rejected.
               return false;        


Is it Compatible with other custom guards ?

Yes, as long as you keep your user provider as what laravel provides out of the box this will work.

Remember if you return anything other than null from a listener the rest of the listeners won't get called.

So if you want to continue the checking process return null.

⚠️ Warning

  • Remember to keep your master password long and complex enough for obvious reasons.

⭐️ Your Stars Make Us Do More ⭐️

As always if you found this package useful and you want to encourage us to maintain and work on it, Please press the star button to declare your willing.

More packages from the author:

💎 A minimal yet powerful package to give you opportunity to refactor your controllers.

💎 A minimal yet powerful package to give a better structure and caching opportunity for your laravel apps.

💎 It allows you login with any password in local environment only.

💎 Authorization and ACL is now very easy with hey-man package !!!

Donate me a Dollar

If you think my work has saved you time and money, please donate me 1 dollar since it's better than donating 0 dollars. ;)

Donate Bitcoin

You can’t perform that action at this time.