hamedov/passport-multiauth
Adds multi-guard authentication to Laravel Passport, letting separate user models and providers (admins, customers, etc.) each issue and validate their own OAuth2 tokens through distinct guards. Simplifies per-guard client credentials, token parsing, and route protection in Laravel APIs.
Architecture fit. The package addresses a real gap in Laravel Passport: Passport's password grant resolves a single user provider, so applications with genuinely separate identity tables (e.g. users, admins, merchants) cannot issue OAuth2 tokens per identity type without custom grant types. This package supplies those grants plus per-guard provider resolution. If our target architecture requires one OAuth2 token endpoint serving multiple distinct identity stores, it is directionally correct. If our need is merely role separation or first-party SPA/mobile auth, it is over-engineered — Passport token abilities/scopes on a single users table, or Sanctum, would cover it with first-party support.
Integration feasibility. Mechanically straightforward: Composer install, publish config, register custom grants in AuthServiceProvider::boot(), define guards/providers in config/auth.php, and optionally apply a trait to identity models. The work is not the wiring; it is validating that the grant correctly binds a request to the intended provider and client. That validation is entirely on us — there are no dependents, no integration examples in the wild, and 5 stars of social proof.
Technical risk — high. Three compounding factors:
League\OAuth2\Server grant types and Passport bridge/bridge-scope internals, which are not covered by Laravel's BC promise. Passport 11/12 changed client model handling, route registration, and hashing behavior; expect breakage on each major.Key questions.
PasswordGrant subclass) cheaper than adoption?My recommendation: do not adopt as a dependency; treat it as a reference implementation. The code volume is small enough that owning a vendored, tested fork — or writing the grant ourselves — is lower total risk than depending on an unmaintained package on the auth path.
Stack fit. Compatible in principle with Laravel + Passport on a standard LEMP/queue stack; no infrastructure requirements, no external services. The constraint is version alignment: pin Laravel and Passport to the exact minor versions the package was written against, and treat any bump as a change requiring a regression pass over all grant flows. This is a coupling we accept only if the feature is genuinely required.
Migration path. Recommended sequence:
If the spike fails or the feature is not mandatory, fall back to single-provider Passport with abilities/scopes, or Sanctum for first-party clients.
Compatibility. Assume breakage on Laravel/Passport majors and budget for it explicitly in the roadmap. Also verify PHP version support, whether the package's service provider uses deferred/auto-discovery registration correctly, and whether its config publishing collides with Passport's own published config. If the package is already stale relative to our target Laravel version, that settles the decision — fork or rewrite, do not adopt.
Sequencing. Auth changes block everything downstream and are the hardest thing to reverse after clients ship. Land the identity model decision (multi-table vs. roles) before any code. Then the grant implementation, then client apps. Do not let mobile/web teams build against a provisional auth contract.
Maintenance. Effectively 100% ours. With zero dependents, we are the only party who will ever file or fix an issue. Plan for a named owner and a recurring quarterly review of the fork against Passport release notes. This is the single largest hidden cost and should be stated in the business case, not buried.
Support. No vendor, no SLA, no maintainer responsiveness assumption. Internal escalation only. On-call runbooks must cover "tokens issued to the wrong provider" as a first-class incident class with a defined containment procedure (revoke by client, force re-auth by provider).
Scaling. No throughput concern — the package adds a provider-resolution lookup per token request, not per API call. Token validation remains Passport's, so runtime cost is negligible relative to the auth endpoints themselves. Scaling risk is organizational (knowledge concentration in one engineer), not technical.
Failure modes.
Mitigations: assert provider identity into token claims at issuance and verify on validation; structured auth logs with provider + client + outcome; alerting on anomalous provider/client pairings; automated cross-provider negative tests in CI.
Ramp-up. Low code volume, high domain knowledge. Any engineer touching this needs working fluency in OAuth2 grant flows, Passport's internals, and our guard/provider topology. Budget for a written design doc and a second engineer cross-trained before production. Given a 5-star, 0-dependent dependency on the credential path, the honest framing to stakeholders is: we are not buying a library, we are buying a starting point and inheriting the security review.
How can I help you explore Laravel packages today?