The Playground authentication and authorization package for Laravel applications.
Read more on using Playground Auth at the Read the Docs for Playground.
You can install the package via composer:
composer require gammamatrix/playground-auth
NOTE: This package is required by Playground: Login Blade
Playground Auth provides information in the artisan about
command.
You can publish the config file with:
php artisan vendor:publish --provider="Playground\Auth\ServiceProvider" --tag="playground-config"
See the contents of the published config file: config/playground-auth.php
The default configuration utitlizes:
- Sanctum
- Users may have additional abilities in the
Playground\Models\User
:users.abilities
- The Playground user model uses a UUID primary key along with additional fields. See the migration for
Playground\Models\User
Depending on your needs, there are multiple middleware, authentication and authorization options available.
Abilities may be used with wildcards at multiple levels. Optionally, these abilities may be used with Sanctum for API Tokens.
Here is an example of the configurable abilities:
'abilities' => [
'root' => [
'*',
],
'admin' => [
'app:*',
'playground:*',
'playground-auth:*',
'playground-cms:*',
'playground-cms-resource:*',
'playground-matrix:*',
'playground-matrix-resource:*',
],
'manager' => [
'app:view',
'playground:view',
'playground-auth:logout',
'playground-auth:reset-password',
// ...
'user' => [
'app:view',
// ...
],
// No abilities for guests:
'guest' => [
'none',
],
// Allow abilities for guests:
'guest' => [
'app:view',
'playground:view',
'playground-auth:logout',
'playground-auth:reset-password',
// ...
- Packages may also be enabled to load privileges with the PLAYGROUND_AUTH_PACKAGES environment variable.
Read more about environment variables in the config/playground-auth.php
on Read the Docs: Playground.
Playground tests many different User model types to support any ecosystem.
Make sure your app is configured for the proper user model in the Laravel configuration:
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => env('AUTH__MODEL', App\Models\User::class),
],
During testing, Playground tests user various models.
config(['auth.providers.users.model' => 'Playground\\Models\\User'])
This package adds a command to hash a password from the command line:
artisan auth:hash-password 'some password'
artisan auth:hash-password 'some password' --json --pretty
{
"hashed": "$2y$10$langzXKRw1GgO6VgF0IrSecqxi3gAsU5NgmmERT\/2pQXg06mSbEjS"
}
composer cloc
Tests at level 9 on:
config/
database/
lang/
resources/views/
src/
tests/Feature/
tests/Unit/
composer analyse
composer format
composer test
Please see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.