Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Mongodb Passport Laravel Package

designmynight/laravel-mongodb-passport

Laravel MongoDB Passport lets you use Laravel Passport’s OAuth2 server with MongoDB, storing clients, tokens, and related Passport data in Mongo collections instead of a relational database. Ideal for Laravel apps already built on MongoDB.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

TPM recommendation: Conditional adopt only for a greenfield Laravel service already standardized on MongoDB and committed to Laravel Passport. Do not adopt for an existing production OAuth deployment without a controlled token-invalidation and rollback plan. For most teams, keeping Passport’s OAuth tables in a relational database while using MongoDB for application data is lower risk.

Architecture fit

  • Fits Laravel applications that use Passport for OAuth2 and want Passport’s client, token, refresh-token, auth-code, and personal-access-client storage in MongoDB.
  • Poor fit where relational integrity, mature migration tooling, or DBA-supported OAuth storage is required. OAuth state is security-sensitive and low-volume; a separate SQL store is often acceptable even in a MongoDB-centric stack.
  • The package is an adapter around Passport’s Eloquent models and MongoDB Laravel driver, so architectural coupling is to both Laravel Passport internals and the MongoDB Eloquent package.

Integration feasibility

  • Greenfield integration is feasible: install the package, configure the MongoDB connection, wire Passport to the package’s MongoDB-backed models, run schema/index setup, and validate all grant types.
  • Brownfield migration is materially harder. Existing access and refresh tokens are opaque credentials and should generally be invalidated rather than migrated; clients and personal-access-client records can be backfilled.
  • Feasibility depends on exact version alignment across PHP, Laravel, Laravel Passport, the MongoDB Laravel driver, and the MongoDB server. A compatibility matrix and CI test suite are mandatory.

Technical risk

  • Low adoption: 66 stars suggests limited production exposure. The recent release date is positive but does not replace a referenceable user base or security-response process.
  • Passport internals: Passport model behavior, token pruning, revocation, scopes, grant flows, and personal-access-client handling can change across major versions. The package may lag upstream.
  • MongoDB semantics: No foreign keys; orphaned tokens and clients are possible. Unique indexes, token lookup indexes, expiry indexes, and TTL behavior must be designed and tested.
  • ID and serialization risk: ObjectId versus integer/string IDs can surface in client IDs, user IDs, personal-access-client relationships, and token introspection paths.
  • Atomicity: Token issuance and refresh rotation may assume transactional behavior. MongoDB transactions require a replica set; standalone deployments can create partial-state risks.
  • Security ownership: OAuth storage failures are auth outages or credential exposure. The adopting team must own key rotation, secret handling, backup encryption, and vulnerability response.

Key questions

  • Which Laravel, Passport, PHP, MongoDB driver, and MongoDB server versions are supported and tested?
  • Does it cover all required grants and features: authorization code, PKCE, password, client credentials, refresh rotation, personal access tokens, scopes, revocation, pruning, and introspection?
  • Are MongoDB indexes, unique constraints, and TTL policies documented and migration-managed?
  • Is the package maintained by one person? Is there a security disclosure path, changelog, and upgrade policy?
  • Can we run Passport on SQL instead, and is that operationally simpler than adding MongoDB OAuth storage?
  • What is the rollback plan if token issuance or validation fails after cutover?

Integration Approach

Stack fit

  • Best fit: Laravel + Passport + MongoDB already operated by the same team, with replica-set MongoDB and established backup, monitoring, and index-management practices.
  • Weak fit: teams without MongoDB operations experience, regulated environments needing mature OAuth vendor support, or applications where Passport is business-critical and uptime-sensitive.
  • If MongoDB is used only for application data, keep Passport in SQL unless there is a hard architectural mandate.

Migration path

  • Greenfield: create MongoDB collections and indexes before enabling Passport; seed clients through controlled admin processes; test every grant flow in staging.
  • Existing SQL-backed Passport: backfill OAuth clients and personal-access-client records; plan to invalidate existing access and refresh tokens and force re-authentication. Do not attempt to migrate opaque token values unless the package explicitly supports the same token representation and hashing model.
  • Use a canary or separate auth service cutover. Keep the SQL schema and prior configuration available for rollback until token issuance and validation are proven.

Compatibility

  • Pin exact versions of the package, Laravel, Passport, and the MongoDB Laravel driver. Do not mix legacy jenssegers/mongodb and newer mongodb/laravel-mongodb packages without confirming package constraints.
  • Validate PHP MongoDB extension availability, replica-set connectivity, TLS, authentication, and connection pooling in every environment.
  • Add automated tests for all grant types, token refresh, revocation, expiry, pruning, personal access tokens, and client authentication.

Sequencing

  1. Run a two-week technical spike: install, wire models, create indexes, and test all required Passport flows.
  2. Produce a compatibility and risk matrix; decide build-versus-fork-versus-SQL alternative.
  3. Design MongoDB collections, unique indexes, TTL policies, backup/restore, and monitoring.
  4. Implement migration for clients only; define token invalidation and user communication.
  5. Staging load and failure testing: MongoDB unavailable, index missing, duplicate token, expired refresh token, clock skew.
  6. Canary production cutover with rollback rehearsal; monitor auth success rate, token issuance latency, and error rates.

Operational Impact

Maintenance

  • Expect ongoing upgrade work as Laravel Passport evolves. The package’s low adoption increases the chance the team must fork, patch, or vendor it.
  • Assign an internal owner for the OAuth storage layer, including dependency upgrades, index migrations, and security reviews.
  • Keep schema/index migrations in the application repository; do not rely on manual MongoDB changes.

Support

  • Assume no commercial support. Escalation is internal engineering plus upstream community issues.
  • Document runbooks for token pruning, key rotation, client registration, emergency token revocation, and MongoDB failover.
  • Monitor token issuance, validation failures, refresh failures, latency, duplicate-key errors, and collection growth.

Scaling

  • OAuth traffic is usually low relative to application traffic; MongoDB can handle it with correct indexes. Ensure indexed lookups by token ID, client ID, user ID, and expiry.
  • Use a replica set for availability and transactions where required. Avoid sharding unless scale genuinely demands it.
  • TTL indexes can control token growth, but verify they do not delete refresh tokens or audit records earlier than policy allows.

Failure modes

  • MongoDB outage causes complete authentication outage for Passport-protected APIs.
  • Missing or incorrect indexes cause slow token validation and timeouts under load.
  • Weak uniqueness constraints allow duplicate tokens or ambiguous client records.
  • TTL or pruning misconfiguration invalidates refresh tokens prematurely.
  • Passport upgrade breaks model assumptions or token lifecycle behavior.
  • Standalone MongoDB prevents transactional token issuance; partial writes may occur.
  • ObjectId serialization or client-ID type mismatches break specific grants or personal access clients.

Ramp-up

  • Team needs working knowledge of Laravel Passport internals, MongoDB schema/index design, replica-set operations, and OAuth failure diagnosis.
  • Budget one to two weeks for a credible spike and three to six weeks for production hardening, migration rehearsal, and runbooks, depending on existing MongoDB maturity.
  • If the team lacks MongoDB operations depth or Passport experience, prefer the SQL-backed Passport path and revisit only after a clear platform mandate.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elsayed85/laravel-api-exceptions
ouhssini/laravel-demo-mode
daworks/ncloud-outbound-mailer-driver
gp247/cms
ignibyte/aic-gates
nexa-merchant/blog
novasa/laravel-language-center
opencage/geocode
adolfoholzer/parameters
livenetworks/ln-starter
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
cgv/localized-resource