pratik-dabhi/laravel-firewall
Laravel firewall middleware for blocking abusive traffic by IP rules such as allow/deny lists and access restrictions. Helps protect routes and applications from unwanted requests with simple configuration and integration into a Laravel app.
Middleware or Filter classes) for repetitive use cases like:
Adopt if:
/login, /api/auth) without over-engineering.Look elsewhere if:
laravel-security.spatie/rate-limiter.laravel-ratelimit).spatie/laravel-activitylog for enrichment.*"This package lets us turn on enterprise-grade security controls in hours—not months—without hiring a security team. For example:
- Block 90% of bot traffic to our checkout page by IP range, reducing fraud costs.
- Geo-block high-risk regions (e.g., Russia) for our US-only SaaS, cutting support overhead.
- Log all blocked attacks automatically, so we’re audit-ready for PCI/GDPR with zero dev effort. The MIT license and active maintenance (last updated March 2026) mean we avoid vendor lock-in. Cost? $0—vs. $5K+/month for a WAF. ROI? Fewer breaches, lower support costs, and faster compliance."*
*"This is a drop-in Laravel middleware that replaces 3–5 custom security classes we’d otherwise write. Key wins:
- IP/CIDR Blocking: Whitelist/blacklist IPs or ranges (e.g.,
192.168.1.0/24) via.envor DB.- GeoIP: Block countries with
MaxMind GeoIP2(we already have the DB license).- Rate Limiting: Protect
/loginwith60 requests/minute/IP—no Redis setup needed (uses Laravel’s cache).- Attack Logging: All blocked requests auto-log to
storage/logs/firewall.logwith IP, endpoint, and reason. Implementation:
composer require pratik-dabhi/laravel-firewall- Add
FirewallMiddlewaretoapp/Http/Kernel.php(runs beforeauth).- Configure rules in
config/firewall.phpor migrate existing rules to the DB. Trade-offs:
- Not a full WAF (no SQLi/XSS protection).
- Rate-limiting uses Laravel’s cache (not Redis)—scale carefully. Alternatives? Only if we need deeper WAF features or real-time IP feeds."*
*"This package fills gaps in Laravel’s native security stack by providing:
- Centralized IP/Geo rules: Manage allow/deny lists via config or DB (e.g., sync with SIEM tools).
- Forensic-ready logs: Structured logs include blocked IPs, endpoints, and timestamps—useful for incident response.
- Integration with existing tools: Works with Laravel’s
auth,throttle, andactivitylogpackages. Recommendation: Pilot on/api/authand/adminendpoints first. Monitor false positives (e.g., legitimate users from blocked regions) and tune rules. Pair with AbuseIPDB feeds for dynamic blocking."*
How can I help you explore Laravel packages today?