Skip to content

gammamatrix/playground-auth

Repository files navigation

Playground Auth

Playground CI Workflow Test Coverage PHPStan Level 9

The Playground authentication and authorization package for Laravel applications.

Read more on using Playground Auth at the Read the Docs for Playground.

Installation

You can install the package via composer:

composer require gammamatrix/playground-auth

NOTE: This package is required by Playground: Login Blade

artisan about

Playground Auth provides information in the artisan about command.

screenshot of artisan about command with Playground Auth.

Configuration

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:

Abilities, Privileges, Roles and Sanctum

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',
// ...

Environment Variables

Read more about environment variables in the config/playground-auth.php on Read the Docs: Playground.

User model types

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'])

Commands

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"
}

Cloc

composer cloc

PHPStan

Tests at level 9 on:

  • config/
  • database/
  • lang/
  • resources/views/
  • src/
  • tests/Feature/
  • tests/Unit/
composer analyse

Coding Standards

composer format

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

About

The Playground authentication and authorization package for Laravel applications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages