mpyw/scoped-auth
Scoped authentication for Laravel: assign different guards and user providers to individual route groups, domains, or tenants so Auth resolves the correct user per context. Handy for multi-tenant and multi-domain apps needing per-scope login without global config changes.
Architecture fit. mpyw/scoped-auth targets a specific Laravel auth gap: applying scope/ownership constraints to authentication and authorization resolution so that a single user model (or guard) can be resolved differently per context (e.g., tenant, role domain, or guard scope). For applications already leaning on Laravel's native gate/policy and guard system, this is a thin, additive layer rather than a framework fork — which is the right shape for a TPM to sponsor. It fits best where multi-tenant or multi-context auth is a first-class domain concern and where the team wants to avoid hand-rolling scope logic into every policy.
Integration feasibility. The package is small in surface area and installable via Composer with no runtime services, no external infrastructure, and no data-store assumptions beyond what Laravel already provides. The v2.1.1 release is a patch: CI coverage for PHP 8.5, a documentation correction for Fortify, and declared support for Laravel 14. There are no migrations, no config-breaking changes, and no deprecations in this release. Integration effort is therefore dominated by our auth model complexity, not by the package.
Technical risk. Three risks are worth naming:
Key questions for the maintainer / our architects.
Stack fit. Assumes Laravel (11+), PHP 8.2+, Composer, and optionally Fortify. It slots into the authorization layer alongside policies and gates rather than replacing them, so it does not force a rewrite of existing AuthServiceProvider or middleware. Applications on a custom auth implementation will see less benefit; applications on stock guards with ad-hoc scope checks in controllers are the strongest fit.
Migration path. Brownfield adoption should be incremental: introduce the package, model one low-risk scope (e.g., read-only tenant isolation on a single resource), validate against existing policy behavior, then expand. There is no data migration — scope resolution is evaluated at request time — which keeps rollback cheap (remove the dependency and the scope bindings).
Compatibility. Laravel 14 and PHP 8.5 are declared; confirm the lower bounds your platform actually runs (Laravel 11/12/13, PHP 8.2–8.4) are still covered by the CI matrix rather than assumed. If we are on Fortify, pin Fortify ≥ 1.33.0 to align with the documented behavior. Pin the package to a minor range (^2.1) rather than floating, given the pace of Laravel-version additions.
Sequencing.
Maintenance. Low ongoing code maintenance: no schema, no background jobs, no config drift. The real maintenance obligation is version tracking — the package adds Laravel version support aggressively, so our dependency-update cadence must include re-running the auth regression suite whenever either the package or Laravel bumps. Budget roughly a half-day per framework minor upgrade for auth regression, not zero.
Support. Support path is upstream GitHub issues from a single primary maintainer. For anything on the authentication path, that is insufficient as a sole escalation route. Mitigation: designate an internal owner (one backend engineer) who can read the package internals and, if needed, vendor a fork. This is a small package; the fork option is credible and should be treated as a live contingency, not a theoretical one.
Scaling. Scope resolution is per-request and in-process, so there is no new network hop or datastore. The scaling concern is query shape: scoped resolution that translates into additional constraints or joins can multiply query count on hot auth paths (every request authenticates). Under Octane, verify no per-request state is retained across workers. Load-test the authenticated path specifically — auth is the one code path every single request traverses, so a 5 ms regression is a fleet-wide 5 ms.
Failure modes.
Ramp-up. Small: an engineer familiar with Laravel guards and policies needs roughly half a day of reading plus the spike to be productive. The non-obvious part is scope precedence semantics, which should be written down internally as a short ADR after the spike so that later contributors don't reverse-engineer intent from behavior. Documentation is community-grade (README plus Fortify notes), so internal documentation is a real deliverable, not overhead.
TPM recommendation. Proceed to a time-boxed feasibility spike (≈3 engineer-days) with a hard go/no-go gate contingent on Fortify verification and a satisfactory answer on multi-scope precedence. Do not adopt broadly before an internal owner is named and the auth regression suite exists. The v2.1.1 release itself carries no migration cost and is a positive maintenance signal — the decision rests on domain fit and single-maintainer risk, not on this changelog.
How can I help you explore Laravel packages today?