承接 ircop/antiflood 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

ircop/antiflood

Composer 安装命令:

composer require ircop/antiflood

包简介

Request flood protection for laravel

README 文档

README

This tool designed for simple limiting some user requests. It makes it easy to add some protection from DB ddos or bruteforce attack.

INSTALL

1: install via composer

composer require ircop/antiflood

2: add service provider to providers array in config/app.php:

Ircop\Antiflood\AntifloodServiceProvider::class,

3: add facade alias to aliases array in config/app.php:

'Antiflood' => Ircop\Antiflood\Facade\Antiflood::class,

Usage

Checking for record existance with given ident.

Ident can be ip-address, login, anything unique.

$maximum - is maximum allowed value for this ident. Default is 1.

\Antiflood::check( $ident, $maximum = 1 );

// Or with IP identity

\Antiflood::checkIP( $maximum = 1 );

Putting record for given ident on given $minutes:

\Antiflood::put( $ident, $minutes = 10 );

// Or with IP identity

\Antiflood::putIP( $minutes = 10 );

Examples:

Limiting wrong login attempts for given IP address:

This example limiting wrong login attempts from one ip-address to 5 tryes per 20 minutes:

public function postLogin()
{
	$key = $_SERVER['REMOTE_ADDR'];
	
	// If this ip has >= 5 failed login attempts in last 20 minutes, redirect user
	// back with error:
	if( \Antiflood::check( $key, 5 ) === FALSE )
		return redirect()->back()->withErrors(['Too many login attempts! Try again later.']);
	
	// ....
	// ....
	// ....

	// After failed login put user ipaddr to antiflood cacte on 20 min.
	// If there is no records with this ident, record will be added with value=1, else
	// it will be increased.
	\Antiflood::put( $key, 20 );
}

Limiting password recovery for 1 try per 30 min.

This code shows how to limit some functions like email, etc. to prevend flood from our server, for example.

public function postPasswordRecover()
{
	$key = \Input::get('email');
	if( \Antiflood::check( $key ) === FALSE )
		return redirect()->back()->withErrors(['.....']);
	
	// ....
	// ....
	// ....

	\Antiflood::put( $key, 20 );
}

统计信息

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

GitHub 信息

  • Stars: 20
  • Watchers: 0
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: GPLv2
  • 更新时间: 2015-11-12

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固