gammamatrix/ playground-auth
Laravel应用的Playground身份验证和授权包。
dev-develop / 73.x-dev
2024-07-06 21:07 UTC
Requires
- php: ^8.2
- gammamatrix/playground: dev-develop|dev-master|dev-feature/*|^73.0@dev|^73.0
Requires (Dev)
- gammamatrix/playground-test: dev-develop|dev-master|dev-feature/*|^73.0@dev|^73.0
This package is auto-updated.
Last update: 2024-09-06 21:34:21 UTC
README
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命令中提供信息。
配置
您可以使用以下命令发布配置文件:
php artisan vendor:publish --provider="Playground\Auth\ServiceProvider" --tag="playground-config"
查看已发布的配置文件内容:config/playground-auth.php
默认配置使用
- Sanctum
- 用户可以在
Playground\Models\User中有额外的能力:users.abilities - Playground用户模型使用UUID主键以及额外的字段。请参阅为
Playground\Models\User的迁移
能力、权限、角色和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', // ...
- 可以通过PLAYGROUND_AUTH_PACKAGES环境变量启用包以加载权限。
环境变量
有关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)。请参阅许可文件以获取更多信息。
