elic-dev/laravel-site-protection
A Laravel package for adding configurable site-wide protection to your application. It uses middleware and Laravel-native configuration to restrict access, shield staging or private sites, and keep unwanted visitors out while authorized users continue smoothly. Simple setup and sensible defaults.
What it is: A lightweight Laravel package that gates site access behind a single shared password form, backed by a session flag. It is not an authentication system — no users, roles, audit trail, or per-identity access control.
Architecture fit: Good fit for monolithic Laravel apps rendering Blade views behind the web middleware group with a shared session store. Poor fit for API-only/stateless services, token-authenticated SPAs, multi-tenant apps requiring per-tenant gates, or anything under compliance (SOC 2, HIPAA) where shared credentials and access logging are required. It also overlaps with existing auth scaffolding (Breeze/Jetstream/Fortify), so middleware ordering and route coverage need deliberate design.
Integration feasibility: High. Expected integration is composer require, publish config, set a password via environment/secret manager, and attach middleware to a route group or the web stack. Realistic effort is hours for a spike, 1–3 days including allowlisting, testing, and rollback documentation. No database migrations or schema changes expected.
Technical risk: Low blast radius but high "security theater" risk if treated as production access control. Key concerns: single shared credential with no revocation per person, unknown brute-force protection/rate limiting, password storage (hashed vs. plaintext comparison), session fixation/regeneration behavior, CDN or response caching potentially serving gated content or caching the password page, and fail-open vs. fail-closed behavior when the session store is unavailable. Low star count (45) implies limited adversarial review.
Key questions:
Stack fit: Best suited to a standard Laravel + Blade monolith on a shared Redis or database session driver. Verify composer.json constraints against the target Laravel version before committing. Confirm coexistence with existing middleware — this should sit early in the web group, after session start and before auth/authorization middleware.
Migration path: Treat it as a pre-launch/staging gate, not a permanent auth layer. Wrap enablement in an environment-scoped config flag so it can be toggled without code changes. Define an exit criterion (e.g., "replaced by SSO/IdP") up front and document removal steps. If already deployed unprotected, sequence the rollout as: staging-only first, then production with a comms plan, since it will lock out all users without the password.
Compatibility: Session driver is the main variable — cookie sessions break under multi-instance deployments without sticky sessions. Edge/CDN caching must be configured to bypass or vary on the session cookie. Inertia/Livewire apps need verification that the password form renders outside the normal layout and that XHR requests receive a redirect rather than a JSON 401. Exclude health checks, webhook endpoints, and asset routes explicitly.
Sequencing:
.env committed to the repo.Maintenance: Minimal code footprint, but maintenance risk is concentrated in a single low-activity maintainer. Pin the version, monitor for Laravel major-version compatibility, and be prepared to fork or vendor the package — it is small enough that internal ownership is viable.
Support: No vendor SLA; community-only with a small user base. Internal on-call must own it. Expect to answer "I'm locked out" tickets, so a documented recovery path (rotate the password via secret manager and redeploy/restart) is mandatory.
Scaling: Negligible performance overhead. The real scaling constraint is the session backend — horizontal scaling requires a shared session store (Redis/database) or sticky sessions. Verify behavior behind a load balancer before any traffic ramp.
Failure modes:
Ramp-up: Trivial for any Laravel developer — under a day to integrate and understand. The non-trivial work is the security review, runbook, and exit plan. Budget for a security sign-off before production use, and treat this as a stopgap control rather than a substitute for real authentication.
How can I help you explore Laravel packages today?