gburtini/bfd
Composer 安装命令:
composer require gburtini/bfd
包简介
Brute force defense: rate limiting tools.
README 文档
README
This hasn't been maintained in years. Use at your own risk and only with the expertise to build it yourself.
A lightweight framework for mitigating brute force attacks in an online architecture.
Right now, there is only one tool, a session-based rate limiter. It is very general and powerful, but there's a lot of work to do here.
Installation
Installation is available via composer.
composer require gburtini/bfd
Usage
SessionThrottle
__construct(string $name, int $safe, int $upper, float $rate, boolean sleep)fail(),succeed()- used to report the outcome of the action being protected, a fail increments the counter and a succeed resets it. (aliased asincrement()andreset()if success/fail don't make sense for your use case)test()- returns true or false to indicate whether you should allow the requested call to take place.
Constructing a SessionThrottle means setting the parameters.
$name- a token for the element, function or method that this SessionThrottle instance is protecting$safe- the number of failures a user gets "free" before they start to get rate limited, you can safely set this quite high for most login related applications.$upper- the highest power of $rate to be used. Out of the box, this is 20 (with rate 1.3) meaning the highest timeout is 1.3^20 = 190 seconds.$rate- the base of the exponent used to calculate the time limit. By default, 1.3. Too large, and the throttler is too aggressive. Too small, and it won't be aggressive enough.$sleep- true/false for whether ->test() should ATTEMPT to always return true (by simply sleeping until the timelimit has passed). Even if sleep is true, the sleep may get interrupted and thus return false. Merely sleeping will not prevent multiple requests for most use-cases. You must check it the return value oftest.
Example use:
use gburtini\bfd\SessionThrottle;
$login_limit = new SessionThrottle("login_bob");
// can have "login" throttles or "login_%username%" throttles... or even just an expensive process can be throttled by this.
if($login_limit->test()) {
if(!checkLogin($user, $pass)) {
$login_limit->fail(); //or ->increment()
} else {
$login_limit->succeed(); // clear the timelimit (or ->reset())
}
} else {
showThrottleError();
}
Future Work
The intent is to collect a whole set of tools for mitigating brute force attacks here. The SessionThrottle tool is just a start:
- Efficient IP-based blocking and throttling.
- Data-level blocking (non-session based limits on access to particular data)
- Global shutdown tools for mitigiating large-scale brute-force attacks.
- Device-cookie tools
License
Copyright (C) 2015 Giuseppe Burtini
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
gburtini/bfd 适用场景与选型建议
gburtini/bfd 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 74 次下载、GitHub Stars 达 5, 最近一次更新时间为 2015 年 04 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「login」 「throttle」 「throttling」 「rate limiting」 「rate limit」 「limit」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gburtini/bfd 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gburtini/bfd 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gburtini/bfd 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
WeChat OAuth SDK
Debugging a problem and need to login as one of your customers? This allows you to authenticate as any of your customers.
A throttler for symfony/http-client to handle rate limits
Simple PHP execution throttler.
A Laravel Pulse card to track users & URL's that are being throttled by your Rate Limiters
Throttle notifications on a per-channel basis
统计信息
- 总下载量: 74
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL
- 更新时间: 2015-04-04