abouvier/slim-access 问题修复 & 功能扩展

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

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

abouvier/slim-access

最新稳定版本:v0.2.0

Composer 安装命令:

composer require abouvier/slim-access

包简介

Access control middleware for Slim framework

README 文档

README

Access control middleware for Slim framework.

Supported formats

  • IPv4 and IPv6 addresses
  • CIDR notation
  • all keyword

Installation

composer require abouvier/slim-access

Usage

Only accept requests from localhost and the 192.168.1.0/24 subnet (except for 192.168.1.42):

use \Slim\Middleware\Access;
// ...
$app = new \Slim\Slim();
// ...
$app->add(new Access([
	'callback' => function () use ($app) {
		$app->halt(403, 'You Shall Not Pass!!!');
	},
	'list' => [
		'::1' => Access::ALLOW,
		'127.0.0.1' => Access::ALLOW,
		'192.168.1.42' => Access::DENY,
		'192.168.1.0/24' => Access::ALLOW,
		'all' => Access::DENY // optional as "all" is already denied by default
	]
]));
// ...
$app->run();

or:

$app = new \Slim\Slim();
// ...
$access = new \Slim\Middleware\Access([
	'callback' => function () use ($app) {
		$app->halt(403, 'You Shall Not Pass!!!');
	}
]);
$access->allow('::1')->allow('127.0.0.1')->deny('192.168.1.42')->allow('192.168.1.0/24')->deny('all');
$app->add($access);
// ...
$app->run();

统计信息

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

GitHub 信息

  • Stars: 7
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2015-09-06