iridiumintel/bad-ip-laravel 问题修复 & 功能扩展

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

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

iridiumintel/bad-ip-laravel

最新稳定版本:v0.0.5

Composer 安装命令:

composer require iridiumintel/bad-ip-laravel

包简介

Laravel wrapper for bad_ip PHP SDK – automatic guards for IP, TOR, queries, bots, and login

README 文档

README

Latest Version License

Laravel wrapper for bad_ip PHP SDK – automatic guards for IP, TOR, bots, bad queries, and login attempts.

🚀 Installation

composer require iridiumintel/bad-ip-laravel

Requires PHP 8.1+ and Laravel 10/11.

⚡️ Quick Start

  1. Publish the config file:
php artisan vendor:publish --tag=badip-config
  1. Add middleware to your app (global or per route):
\BadIp\Laravel\Middleware\BadIpMiddleware::class,

🔥 Features

  • Automatic protection against:
    • Malicious IPs
    • TOR exit nodes
    • Bots
    • Bad queries (on 404 pages with query string)
    • Brute force login attempts
  • Automatic incident reporting back to the Bad IP API
  • Config-driven guard activation

⚙️ Configuration

File: config/badip.php

return [
    'token' => env('BADIP_TOKEN', ''),
    'base_url' => env('BADIP_BASE_URL', 'https://bad-ip.iridiumintel.com/api/v1'),
    'login_attempts' => env('BADIP_LOGIN_ATTEMPTS', 3),
    'guards' => [
        'ip' => true,
        'tor' => true,
        'bot' => true,
        'query' => true,
        'login' => true,
    ],
];

🧑‍💻 Usage

Global Middleware

protected $middleware = [
    \BadIp\Laravel\Middleware\BadIpMiddleware::class,
];

Separate Middleware

If you prefer finer control, use individually:

\BadIp\Laravel\Middleware\CheckBadIp::class,
\BadIp\Laravel\Middleware\CheckTorMiddleware::class,
\BadIp\Laravel\Middleware\CheckBotMiddleware::class,
\BadIp\Laravel\Middleware\CheckBadQuery::class,
\BadIp\Laravel\Middleware\LoginGuardMiddleware::class,

Incident Reporting

use BadIp\RequestContext;
use BadIp\Laravel\Support\Helpers;

// Report bad query
$reporter->reportQuery(RequestContext::fromGlobals(), Helpers::origin());

// Report failed login
$reporter->reportLoginFailure(RequestContext::fromGlobals(), Helpers::origin());

// Report generic 404
$reporter->report404(RequestContext::fromGlobals(), Helpers::origin());

🧪 Testing

composer test

🤝 Contributing

Contributions are welcome! Please see the contributing guide.

📄 License

The MIT License (MIT). See LICENSE for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-11