vcian/laravel-ip-gateway
Laravel IP Gateway adds middleware and configuration for restricting access by IP address. Easily allow or deny requests, protect routes, and manage whitelists or blacklists with a simple Laravel-friendly setup.
What it is (to be verified against source): A Laravel package providing middleware-based IP allow/deny gating, most likely with config-driven and/or database-backed rules and CIDR matching. At 43 stars, one maintainer, and a single release dated 2024-08-23, it has low adoption signal and should be classified as an unvetted third-party dependency until a code review is complete.
Architecture fit: Strong conceptually. IP gating is a cross-cutting concern that belongs in middleware, and a thin middleware layer slots into the HTTP kernel with minimal coupling. The fit degrades if the package owns its own table and models, creating a second source of truth for access policy alongside the edge WAF/ingress allowlist. Position it as application-layer defense-in-depth for internal surfaces (admin panels, Horizon/Telescope, webhooks, staging), not as the primary perimeter control.
Integration feasibility: High. Composer install, publish config/migrations, register the middleware and alias, apply to route groups. Engineering effort is likely 0.5–2 days for a working spike; the real cost is policy definition, trusted-proxy configuration, and operating model, not code.
Technical risk: Low-to-medium code risk, medium governance risk.
X-Forwarded-For without a strict trusted-proxy configuration, the gate is trivially spoofable — a silent hole, not a visible failure.Key questions to answer before adoption:
composer.json for Laravel and PHP versions; is it Octane-safe (no request state retained in singletons)?Stack fit: Suitable for standard Laravel HTTP stacks across web and API middleware groups. It complements rather than replaces edge controls (WAF, ingress allowlists, VPN/Zero Trust). The highest-value use cases are low-blast-radius: hardening /admin, /horizon, /telescope, internal-only APIs, and partner webhook endpoints where a source-IP allowlist is contractually expected.
Migration path: Introduce side-by-side, not as a replacement.
Compatibility: Verify declared Laravel/PHP constraints against the target services first. Check middleware ordering relative to auth, session, and throttle — IP gating should generally run early, before expensive auth work, but after trusted-proxy normalization. Confirm Octane compatibility and that rule caching uses the shared cache store rather than per-process memory. Confirm migrations run and roll back cleanly on a scratch database.
Sequencing:
Maintenance: Expect low churn in the code itself, but the package is effectively in a quiet state — a year-plus without a release means dependency drift will accumulate against Laravel and PHP majors. Budget roughly 1–2 days per quarter to verify compatibility, or plan to fork and maintain a two-file middleware in-house if the dependency becomes load-bearing. A fork is cheap here; that materially caps the risk.
Support: No vendor SLA. GitHub issues only, from a small maintainer. Require a named internal owner with the ability to read and patch the middleware. Acceptable for internal tooling and admin surfaces; not acceptable on a customer-facing path with contractual availability commitments.
Scaling: Per-request cost is negligible (string/bitmask comparison) provided rules are cached rather than queried per request. Watch two things: rule-set size growth turning into per-request table scans, and cache invalidation across nodes. The middleware is stateless, so horizontal scaling and Octane are fine if the cache is shared and rule updates propagate reliably — otherwise nodes diverge and produce inconsistent access decisions.
Failure modes and mitigations:
X-Forwarded-For and expects rejection.Ramp-up: A Laravel-fluent engineer is productive in roughly half a day. The real ramp cost is operational, not technical: who owns the rule set, how changes are reviewed and approved, how break-glass access is granted, and how deny spikes are triaged. Assign that ownership before enabling enforcement — an unowned IP allowlist becomes an outage generator.
Bottom line: Reasonable as a scoped, internal hardening layer behind a solid edge control plane, introduced in shadow mode with a trusted-proxy config fixed first and a low-cost exit (wrapper + fork option). Not a candidate for primary perimeter security, customer-facing availability paths, or any deployment where the team cannot own and patch the middleware itself.
How can I help you explore Laravel packages today?