smashed-egg/laravel-in-memory-auth

This package allows you to Authenticate an admin area without the need for a database.

0.2.0 2023-09-28 08:48 UTC

This package is auto-updated.

Last update: 2024-04-04 09:10:26 UTC


README

main.jpg

Laravel In Memory Auth Provider

Latest Stable Version Downloads this Month

An In Memory User Auth Provider for Laravel 9+.

Allows you to Authenticate an admin area without the need for a database. Great as a quick and temporary solution during development, particularly if your site is mocked out and not let using a database.

Requirements

  • PHP 8.0.2+
  • Laravel 9.0+

Installation

To install this package please run:

composer require smashed-egg/laravel-in-memory-auth

Support Me

Do you like this package? Does it improve you're development. Consider sponsoring to help with future development.

Buy me a coffee!

Thank you!

Configuration

Setup config

In the auth.php config file you will need to set the driver:

'driver' => 'memory',

Add also setup your in memory users:

'memory' => [
    'driver' => 'memory',
    'model' => \SmashedEgg\LaravelInMemoryAuth\User::class,
    'username_field' => 'email',
    'users' => [

        /*
         'me@email.com' => [
            'id' => 1,
            'name' => 'My name',
            // Hashed password using the hasher service
            'password' => 'hashed_password',
        ],
         */

        'admin@example.com' => [
            'id' => 1,
            'email' => 'admin@example.com',
            'name' => 'Barry Allen'
            // Hashed password using the hasher service
            'password' => '$2y$10$Mfusxb1546MFxQ4A1s4GE.OF/gFuI8Y6Hw9xnlZeiHtjDl0/pnXPK',
            'remember_token' => '',
        ],
    ],
],

You can add any properties you want making it easy to switch out the Auth drivers.

The package comes with a command for hashing passwords, making it easier to setup passwords, just run the following command to hash your password:

php artisan smashed-egg:hash:password mypassword

Contributing

Contributing is welcome. Please see our guide here.

License

This package is open-sourced software licensed under the MIT license.