rawaby88 / portal
门户
3.0.1
2023-03-15 12:07 UTC
Requires
- php: ^7.3 || ^8.0 || ^8.1 || ^8.2
- ext-json: *
- ext-openssl: *
- doctrine/dbal: ^3.1
- goldspecdigital/laravel-eloquent-uuid: ^8.0 | ^9.0 | ^10.0
- illuminate/contracts: ^8.0 | ^9.0 | ^10.0
- illuminate/database: ^8.0 | ^9.0 | ^10.0
- illuminate/support: ^8.0 | ^9.0 | ^10.0
Requires (Dev)
- orchestra/testbench: ^6.0 | ^7.0 | ^8.0
- phpunit/phpunit: ^9.0
- dev-main
- 3.0.1
- 3.0.0
- 2.4.6
- 2.4.5
- 2.4.4
- 2.4.3
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.1
- 2.3.0
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.6
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.2
- 2.0.1
- 2.0
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.0
- 1.1.1
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.1
- 0.9.1
- 0.6.0
- 0.5.0
- 0.4.2
- 0.4.1
- 0.3.2
- 0.3.1
- 0.3.0
- 0.2.4
- 0.2.3
- 0.2.0
- 0.1.0
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
This package is auto-updated.
Last update: 2024-09-15 15:36:14 UTC
README
此包添加了新的守护者 ['portal'],用于认证路由。
它将检查用户是否有有效的令牌和访问端点的权限
安装
您可以通过composer安装此包
composer require rawaby88/portal
用法
将Portable特质添加到User模型中;
use Rawaby88\Portal\Portable; use Portable;
运行migrate以更新用户表
php artisan migrate
迁移定制
如果您不打算使用Portal的默认迁移,应在您的
Portal::ignoreMigrations();
的注册方法中调用方法
App\Providers\AppServiceProvider class.
您可以通过执行以下命令导出默认迁移
php artisan vendor:publish --tag=portal-migrations
通过在端点添加中间件 'auth:portal' 来使用
Route::middleware('auth:portal')->get('/user', function (Request $request) { return auth()->user()->token; });
auth() 函数将可供您使用
auth()->check(); auth()->id(); auth()->user(); auth()->user()->token; auth()->user()->appliance; //you can also call other param as credit auth()->user()->getData('credit'); auth()->user()->getData('workspace');
如果您想更改用户表中存储的数据,您可以通过执行以下命令导出默认配置
php artisan vendor:publish --tag=portal-config
[/config/portal.php]
return [ 'auth_endpoint' => env( 'PORTAL_AUTH_ENDPOINT', '172.17.0.1/api/auth/token/check/' ), 'expiration' => null, //user mode namespace 'user_model' => env( 'PORTAL_USER_MODEL', 'App\Models\User' ), // Mapping data from response to database //add or remove fields as you wish 'db_user_fields' => [ 'id' => 'user_id', 'name' => 'name', 'email' => 'email' ], // primary key for user table 'user_model_key' => 'user_id', // primary key type -- don't change 'user_model_key_type' => 'string', ];
安全性
如果您发现任何安全相关的问题,请通过电子邮件 github@dreamod.pl 而不是使用问题跟踪器。
鸣谢
许可证
MIT许可证(MIT)。请参阅许可证文件以获取更多信息。