gammamatrix/playground-auth

Laravel应用的Playground身份验证和授权包。

dev-develop / 73.x-dev 2024-07-06 21:07 UTC

This package is auto-updated.

Last update: 2024-09-06 21:34:21 UTC


README

Playground CI Workflow Test Coverage PHPStan Level 9

Laravel应用的Playground身份验证和授权包。Laravel

在Playground的Read the Docs上了解更多关于使用Playground Auth的信息。Read the Docs for Playground

安装

您可以通过composer安装此包

composer require gammamatrix/playground-auth

注意:此包需要Playground: Login Blade

artisan about

Playground Auth在artisan about命令中提供信息。

screenshot of artisan about command with Playground Auth.

配置

您可以使用以下命令发布配置文件:

php artisan vendor:publish --provider="Playground\Auth\ServiceProvider" --tag="playground-config"

查看已发布的配置文件内容:config/playground-auth.php

默认配置使用

能力、权限、角色和Sanctum

根据您的需求,有多种中间件、身份验证和授权选项可供选择。

能力可以在多个级别使用通配符。可选地,这些能力可以与Sanctum一起用于API令牌。

以下是可以配置的能力示例

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

环境变量

有关config/playground-auth.php中的环境变量的更多信息,请参阅Read the Docs: Playground

用户模型类型

Playground测试了许多不同的用户模型类型以支持任何生态系统。

确保您的应用程序在Laravel配置中已正确配置为适当的用户模型

    'providers' => [
        'users' => [
            'driver' => 'eloquent',
            'model' => env('AUTH__MODEL', App\Models\User::class),
        ],

在测试过程中,Playground测试了各种模型。

config(['auth.providers.users.model' => 'Playground\\Models\\User'])

命令

此包添加了一个命令,可以从命令行哈希密码

artisan auth:hash-password 'some password'
artisan auth:hash-password 'some password' --json --pretty
{
    "hashed": "$2y$10$langzXKRw1GgO6VgF0IrSecqxi3gAsU5NgmmERT\/2pQXg06mSbEjS"
}

Cloc

composer cloc

PHPStan

在第9级进行测试

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

编码规范

composer format

测试

composer test

变更日志

请参阅CHANGELOG以获取有关最近更改的更多信息。

致谢

许可

MIT许可(MIT)。请参阅许可文件以获取更多信息。