usmonaliyev/env-auth
最新稳定版本:1.1.0
Composer 安装命令:
composer require usmonaliyev/env-auth
包简介
The package provides middleware for Laravel applications to handle Basic Authentication and Secret Key Authentication using credentials stored in the .env file.
关键字:
README 文档
README
The package provides middleware for Laravel applications to handle Basic Authentication and Secret Key Authentication using credentials stored in the .env file.
Installation
You can install the package via composer:
composer require usmonaliyev/env-auth
Publish
Publish the package configuration:
php artisan vendor:publish --provider="Usmonaliyev\EnvAuth\EnvAuthServiceProvider"
Configuration
Add the necessary credentials to your .env file.
If you want to modify keys of variables, you need to change config/env-auth.php after publish config file.
For BasicEnv middleware:
BASIC_USERNAME=your-username BASIC_PASSWORD=your-password
For SecretEnv middleware:
AUTH_SECRET_KEY=your-secret-key
Usage
Register middleware
If you are using Laravel 11.x check out this link: https://laravel.com/docs/11.x/middleware#middleware-aliases
In your Laravel application's app/Http/Kernel.php file, register the new middleware classes:
protected $routeMiddleware = [ // Other middleware 'basic.env' => \Usmonaliyev\EnvAuth\Middleware\BasicEnv::class, 'secret.env' => \Usmonaliyev\EnvAuth\Middleware\SecretEnv::class, ];
Protect routes
Apply the middleware to your routes in routes/web.php or routes/api.php.
Route::middleware('basic.env')->group(function () { ... });
Testing
Use the following cURL command to test Basic Authentication:
curl -u your-username:your-password http://your-app-url/basic-protected-route
Contributing
Please see CONTRIBUTING for details.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 253
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-06-24