Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Firewall Laravel Package

moox/firewall

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Layered Security: Moox Firewall integrates seamlessly as an application-level middleware in Laravel, complementing existing security layers (e.g., Laravel’s built-in auth, rate limiting, or CSRF protection). It does not disrupt core architecture but adds a pre-authentication barrier, aligning with the defense-in-depth principle.
  • Stateless Design: Leverages IP whitelisting (stateless) without session dependency, reducing attack surface for brute-force or credential-stuffing attempts.
  • Backdoor Isolation: The token-based backdoor is opt-in and configurable, ensuring it doesn’t interfere with normal operations unless explicitly enabled.

Integration Feasibility

  • Middleware Hook: The package registers a kernel middleware (FirewallMiddleware), which can be inserted into Laravel’s HTTP pipeline before auth middleware (e.g., auth:api or web). This ensures IP checks occur before authentication, blocking malicious traffic early.
  • Filament Compatibility: Explicit support for Filament admin panels suggests minimal friction for SPAs or admin interfaces, where IP restrictions are critical.
  • Config-Driven: All rules (whitelist, backdoor) are environment/configurable, enabling zero-code changes for basic use cases.

Technical Risk

  • IP Spoofing: Whitelisting alone is not foolproof (e.g., VPNs, proxies, or shared hosting). Mitigation: Combine with user-agent fingerprinting or geolocation (if needed).
  • Backdoor Security: The token-based backdoor, while useful, introduces a single point of failure. Risks:
    • Token leakage (e.g., via logs, env vars).
    • Lack of rate limiting on backdoor attempts (planned in future releases).
    • Workaround: Use short-lived tokens (e.g., generated via artisan commands) or integrate with Laravel Sanctum/Passport for token validation.
  • Performance Overhead: IP lookups in whitelist are O(n). For large whitelists (>10K IPs), consider:
    • Optimization: Use a Bloom filter or database-backed lookup (e.g., Redis).
    • Caching: Cache resolved IPs (e.g., request()->ip() can vary behind load balancers).
  • False Positives: Shared hosting or CDNs (e.g., Cloudflare) may obfuscate real IPs. Requires:
    • Configurable trusted_proxies (Laravel’s trustProxies()) alignment.
    • Testing with real-world traffic (e.g., staging environments).

Key Questions

  1. Deployment Scope:
    • Should the firewall apply to all routes or only sensitive ones (e.g., /admin)?
    • How to handle APIs (e.g., GraphQL, REST) vs. web routes?
  2. IP Management:
    • How to dynamically update whitelists (e.g., via database, API, or admin panel)?
    • Support for IP ranges/CIDR blocks (currently limited to comma-separated IPs).
  3. Backdoor Governance:
    • Token rotation policy (e.g., auto-expiry, single-use).
    • Audit logging for backdoor access.
  4. Observability:
    • Integration with Laravel’s logging or SIEM tools for blocked requests.
    • Alerting for failed backdoor attempts.
  5. Future-Proofing:
    • Will the package support MFA/Passkeys (as per roadmap)? How will this interact with existing auth?
    • Plans for geoblocking or device fingerprinting?

Integration Approach

Stack Fit

  • Laravel Ecosystem: Native support for Laravel’s service providers, middleware, and config system. No framework-specific hacks required.
  • Filament Admin Panels: Pre-built UI for managing whitelists/backdoors, reducing dev effort.
  • Composer Dependency: Lightweight (~1MB) with zero runtime dependencies beyond Laravel core.

Migration Path

  1. Pilot Phase:
    • Install via Composer and publish config.
    • Enable in staging with a small whitelist (e.g., dev IPs + trusted services).
    • Test with manual IP rotation to validate behavior.
  2. Gradual Rollout:
    • Phase 1: Apply to admin routes only (e.g., /admin/*).
    • Phase 2: Extend to API endpoints (if critical).
    • Phase 3: Enable for public-facing routes (if business logic permits).
  3. Backdoor Deployment:
    • Generate a temporary token via CLI (artisan firewall:token) and document its usage.
    • Restrict backdoor to HTTPS-only and specific paths (e.g., /backdoor).

Compatibility

  • Laravel Versions: Tested with Laravel 10+ (as of 2026). Verify compatibility with:
    • PHP 8.1+ (for named arguments, attributes).
    • Laravel Fortify/Sanctum (if using custom auth).
  • Proxy/CDN Support:
    • Configure trusted_proxies in AppServiceProvider to ensure request()->ip() resolves correctly.
    • Example:
      TrustedProxy::ips(['192.168.1.1', '10.0.0.1']); // Your load balancer IPs
      
  • Caching Layers:
    • If using Varnish/Nginx caching, ensure X-Forwarded-For headers are trusted and passed through.

Sequencing

  1. Pre-Installation:
    • Audit current IP-based restrictions (e.g., .htaccess, cloud WAF rules).
    • Document whitelist requirements (e.g., CI/CD IPs, third-party services).
  2. Installation:
    • Run composer require moox/firewall and publish config.
    • Configure MOOX_FIREWALL_WHITELIST in .env (e.g., 192.0.2.1,203.0.113.5).
  3. Middleware Registration:
    • Add to app/Http/Kernel.php before auth middleware:
      protected $middleware = [
          \Moox\Firewall\Http\Middleware\FirewallMiddleware::class,
          \App\Http\Middleware\TrustProxies::class,
          // ... other middleware
      ];
      
  4. Testing:
    • Use curl or Postman to test:
      • Blocked requests (non-whitelisted IPs).
      • Backdoor access (with token).
    • Monitor logs for FirewallMiddleware events.

Operational Impact

Maintenance

  • Configuration Drift: Centralize whitelist management via:
    • Environment variables (for dev/staging).
    • Database-backed whitelist (for production, using a firewall_ips table).
  • Token Management:
    • Implement a token revocation system (e.g., store tokens in DB with expiry).
    • Use Laravel’s encrypted strings for sensitive config.
  • Updates:
    • Monitor for new releases (e.g., MFA support).
    • Test major Laravel version upgrades (e.g., 10 → 11).

Support

  • Incident Response:
    • Locked-out admins: Ensure backdoor tokens are documented offline (e.g., printed QR code).
    • False blocks: Provide a bypass procedure (e.g., temporary config override).
  • User Education:
    • Train teams on whitelist updates (e.g., adding new office IPs).
    • Document backdoor usage policies (e.g., "tokens expire after 24 hours").

Scaling

  • Performance:
    • For high-traffic sites, optimize IP lookups:
      • Use Redis for whitelist storage (e.g., SISMEMBER for O(1) lookups).
      • Example Redis setup:
        $whitelist = new Redis();
        $whitelist->sAdd('firewall_whitelist', '192.0.2.1');
        
    • Load testing: Simulate 10K RPS to validate latency impact.
  • Geographic Scaling:
    • If using global CDNs, ensure whitelist IPs are region-agnostic or use geolocation services (e.g., MaxMind).

Failure Modes

Failure Scenario Impact Mitigation
Whitelist misconfiguration Legitimate users blocked Rollback via backdoor; implement dry-run mode.
Token leakage Unauthorized backdoor access Rotate tokens immediately; log all backdoor usage.
IP spoofing (e.g., VPNs)
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver