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.
composer require mpyw/scoped-auth. v2.1.1 is a compatibility/maintenance release, so there are no new setup steps compared with v2.1.0.laravel/fortify >= 1.33.0 for the documented fix.config/auth.php guards/providers before writing application code. The package is most useful when you need more than one authentication context in the same app, such as web for customers and a separate admin scope for staff.web guard. Log in through both scopes in the same browser session and verify that each scope resolves its own user independently.php artisan route:list, then exercise login, logout, and “remember me” behavior for each scope. This quickly exposes session-key or middleware-order mistakes.$request->user('admin') over the global Auth::user() when a route can be reached by multiple user types.auth middleware alone in multi-scope areas.@auth check is usually too broad when customer and admin sessions can coexist.actingAs($user, 'admin') or the package’s equivalent scope-aware helper, and assert that logging out of one scope does not affect the other. Cover both scopes in feature tests, not just unit tests.Auth::user()/auth()->user() calls.php artisan config:clear. Stale config is a frequent source of “wrong user” bugs in multi-guard applications.Auth::guard('admin')->check() and compare it with Auth::user(). Also inspect session keys when logout behavior looks inconsistent.How can I help you explore Laravel packages today?