damianchojnacki/access-token
Composer 安装命令:
composer require damianchojnacki/access-token
包简介
Site access token for Laravel apps.
README 文档
README
This package protects site from viewing by regular users. Only the ones who know unique token can access site.
WARNING! This package DOES NOT ensure high level of protection! It is intended to prevent viewing site by regular users. For real authentication use proper package like Laravel Passport.
Requirements
It requires PHP 7.4+ and Laravel 5.8+.
Installation
- Install package using composer:
composer require damianchojnacki/access-token
- Create .env configuration variables:
ACCESS_TOKEN= ACCESS_EXPIRATION=
You can specify here your access token and expiration time in minutes (default 1 day).
Usage
To make usage easier there is helper middleware that validates token. If it was not found 403 error is thrown.
You can guard whole site by placing middleware into Kernel.php file
protected $middleware = [ \Damianchojnacki\AccessToken\CheckAccessToken::class, ];
If you want to guard specific route you can define named middleware:
protected $routeMiddleware = [ 'access-token' => \Damianchojnacki\AccessToken\CheckAccessToken::class, ];
There is also command for generating new token:
php artisan access-token:generate
[OK] Access token saved to .env file. You can now access your site by visiting url below:
https://example.com?token=3md3Q8sLYNMCVrMvqaw67FSnUvC7d9gN
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 69
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-12-23