aalfiann/url-param-firewall
Composer 安装命令:
composer require aalfiann/url-param-firewall
包简介
A PSR7 middleware for url parameter firewall for Slim Framework 3
README 文档
README
A PSR7 middleware for url parameter firewall for Slim Framework 3.
Why we should create firewall for url parameter?
- To prevent from ddos layer 7 which is targeting to attack using random url parameters.
- To prevent useless webpage cache.
- To avoid BOT goes to wrong url.
- To hardening the CSRF and XSS attack.
- Etc.
So you better to whitelisting url parameter for each routes.
Installation
Install this package via Composer.
composer require "aalfiann/url-param-firewall:^1.0"
Usage
use \Psr\Http\Message\ServerRequestInterface as Request; use \Psr\Http\Message\ResponseInterface as Response; use \aalfiann\middleware\ParamFirewall; $app->get('/', function (Request $request, Response $response) { $body = $response->getBody(); $body->write('You will see this message if passed url firewall'); return $response->withBody($body); })->(new ParamFirewall(['_','page']))->setName("/");
Open browser and now make a test:
http://yourdomain.com/ >> WORK
http://yourdomain.com/?page=1 >> WORK
http://yourdomain.com/?page=1&_=3123123 >> WORK
http://yourdomain.com/?product=test >> 404
http://yourdomain.com/?page=1&_=3123123&product=test >> 404
Note:
We should allow url param name _ because it used in jquery ajax cache.
统计信息
- 总下载量: 18
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-09-27