Code Monkey home page Code Monkey logo

laravel-anypass's Introduction

Laravel Anypass

anypass_header

Latest Stable Version Quality Score Build Status License Check Imports StyleCI

Built with โค๏ธ for every "lazy" laravel developer ;)

It is always painful to remember and type in the correct password in the login form while you are in development...

It would be nice to be able to login with any password in local environment and only by changing the .env variables(not the application code), switch to: "real password checking".

(This means you do not need to change your application code, when you deploy your app to production while you enjoy the ease in local environments.)

Actually the behaviour of the auth()->attempt($credentials); simply changes based on the config variable in the auth.php and .env file!

Performance hit:

This package is only a few lines (about 20 lines) of code with almost no overhead.

It is also completely safe to avoid installing it on production without changing your code. Since it is a dev only dependency in your composer.json file.

  "require-dev": {
       "imanghafoori/laravel-anypass": "dev-master",
        ...
  },

Config

To avoid accidental security vulnerabilities, 3 conditions should match before you can login with any password :

in your .env file you must:

1 - APP_ENV=local  // or APP_ENV=testing
2 - APP_DEBUG=true
3 - ANY_PASS=true
4 - WRONG_ANY_PASS=wrong // any password is correct except this one.

That way it is very unlikely to accidentally misconfigure your app to accept any wrong password on production server.

We highly recommend to take a look to the source code.

By default, Anypass will only work if the APP_ENV is set to local or testing. You can override this by defining ANY_PASS_ENVIRONMENTS in your .env file, and setting the value to a comma-separated string of environments. For example:

ANY_PASS=true
ANY_PASS_ENVIRONMENTS="local,testing,acceptance"
  • If you want to manually check the login form behaivour in case of a wrong password in local you can use the "1_Wrong_pass" string. (you CAN enter it in lowercase or uppercase and a combination of both like "1_WrOnG_Pass", and it would be considered as a wrong password.)

๐Ÿ’“ Note

You can not login with an invalid username or an invalid api token. Only the password checking is by-passed.

๐Ÿ”ฅ Installation

composer require --dev imanghafoori/laravel-anypass

(For laravel 5.4 and below: Instead of adding the service provider in the config/app.php file, you can add the following code to your app/Providers/AppServiceProvider.php file, within the register() method:

public function register()
{
    if ($this->app->environment() === 'local' || $this->app->environment() === 'testing') {
        $this->app->register(\Imanghafoori\AnyPass\AnyPassServiceProvider::class);
    }
    // ...
}

โ— Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

โญ 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 from the author:

Laravel Terminator

๐Ÿ’Ž A minimal yet powerful package to give you opportunity to refactor your controllers.


Laravel Widgetize

๐Ÿ’Ž A minimal yet powerful package to give a better structure and caching opportunity for your laravel apps.


Laravel Master Pass

๐Ÿ’Ž A simple package that lets you easily impersonate your users.


Laravel HeyMan

๐Ÿ’Ž It allows to write exressive and defensive code whcih is decoupled from the rest of your app.


laravel-anypass's People

Contributors

amirsadeghi1 avatar cyberhicham avatar imanghafoori1 avatar laravel-shift avatar muhammadmp97 avatar rahi69 avatar reziamini avatar sjorso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-anypass's Issues

Laravel 6.x compatibility

Could you upgrade this package for Laravel 6.x ?
You probably should only upgrade the composer requirements to allow Laravel 6.x releases

Tag for PHP 8

Could you please tag the latest version that support PHP 8?

This doesn't work based on .ENV variables

I have just installed and tested this package.

I have the following in my .ENV:

APP_ENV=local
APP_DEBUG=true
ANY_PASS=true

I then changed the config/auth.php so that it uses anyPass as you showed in this issue:

'providers' => [
        'users' => [
            'driver' => 'eloquentAnyPass',
            'model' => App\Models\User::class,
        ]
    ],

So now I can log in with any password which is fine.

However if I change ANY_PASS=false or APP_DEBUG=false and then clear my config cache it still allows me to log in with any password. There is no checking to see if we are on a local environment which is a very dangerous move.

Testing on Laravel 5.6 on PHP 7.2.5

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.