weldon/env-auth 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

weldon/env-auth

最新稳定版本:v1.0.0

Composer 安装命令:

composer require weldon/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

Packagist Dependency Version Total Downloads Latest Version on Packagist Packagist License

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 weldon/env-auth

Publish

Publish the package configuration:

php artisan vendor:publish --provider="Weldon\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' => \Weldon\EnvAuth\Middleware\BasicEnv::class,
    'secret.env' => \Weldon\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.

统计信息

  • 总下载量: 181
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-21