jalallinux/laravel-shield 问题修复 & 功能扩展

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

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

jalallinux/laravel-shield

最新稳定版本:1.2.4

Composer 安装命令:

composer require jalallinux/laravel-shield

包简介

A HTTP basic auth middleware for Laravel

README 文档

README

A HTTP basic auth middleware for Laravel.

Latest Version on Packagist Tests Total Downloads

// Use on your routes.
Route::get('/', ['middleware' => 'shield'], function () {
    // Your protected page.
});

// Use it within your controller constructor.
$this->middleware('shield');

// Use specific user credentials.
$this->middleware('shield:jalallinux');

Installation

Require this package, with Composer, in the root directory of your project.

composer require jalallinux/laravel-shield

Add the middleware to the $routeMiddleware array in your Kernel.php file.

'shield' => \JalalLinuX\Shield\ShieldMiddleware::class,

Configuration

Laravel Shield requires configuration. To get started, you'll need to publish all vendor assets:

php artisan vendor:publish --provider JalalLinuX\\Shield\\ShieldServiceProvider

This will create a config/shield.php file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases.

HTTP Basic Auth Credentials

The user credentials which are used when logging in with HTTP basic authentication.

Usage

To protect your routes with the shield you can add it to the routes file.

Route::get('/', ['middleware' => 'shield'], function () {
    // Your protected page.
});

You can also add the shield middleware to your controllers constructor.

$this->middleware('shield');

The middleware accepts one optional parameter to specify which user credentials to compared with.

$this->middleware('shield:jalallinux');

To add a new user, you probably want to use hashed credentials. Hashed credentials can be generated with the password_hash() function in the terminal:

php -r "echo password_hash('my-secret-passphrase', PASSWORD_DEFAULT);"

Then copy and paste the hashed credentials to the .env environment file.

SHIELD_USER=your-hashed-user
SHIELD_PASSWORD=your-hashed-password

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-01-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固