smashed-egg / laravel-in-memory-auth
This package allows you to Authenticate an admin area without the need for a database.
Requires
- php: ^8.0.2
- illuminate/console: ^9.21|^10.0
- illuminate/contracts: ^9.21|^10.0
- illuminate/support: ^9.21|^10.0
Requires (Dev)
- orchestra/testbench: ^7.6|^8.0
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-11-04 10:22:34 UTC
README
Laravel In Memory Auth Provider
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.
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.