juststeveking/laravel-bastion
Laravel Bastion gives your Laravel application a fortified foundation, bundling the conventions and groundwork you'd otherwise rebuild for every project so you can focus on shipping features. Lightweight, framework-friendly, and simple to drop into new or existing apps.
Architecture fit. Bastion targets a specific and legitimate slot: long-lived bearer credentials for machine-to-machine and partner-facing APIs, with Stripe-style semantics — environment-scoped keys, per-key scopes, revocation. That is distinct from Sanctum (first-party SPA/session tokens) and Passport (full OAuth2 grants and refresh flows). It fits when the credential subject is an organization, integration, or service rather than an end user, and when the product needs a test/live separation story that external developers already understand from Stripe. It does not fit consumer login, social sign-on, enterprise SSO, delegated authorization, or OAuth2. Adopting it also means operating a second authentication system alongside whatever authenticates humans — a real architectural cost that must be justified by an actual API or partner roadmap, not by convenience.
Integration feasibility. The install surface is small and conventional: composer install, publish config and migrations, add a trait to the authenticatable model, register a middleware alias, attach it to route groups with scope arguments. A Laravel engineer familiar with Sanctum completes a working spike in under a day. The expensive work is what the package deliberately leaves to the adopting team: key lifecycle policy, scope taxonomy, environment mapping, rotation and revocation workflow, and the customer-facing issuance experience. That is product and policy effort measured in weeks, and it should be planned and resourced as such — the library is the cheap part.
Technical risk. Ecosystem validation is thin: ~109 stars, zero dependents, a 0.0.2 release line, a single maintainer, and an opportunity score under 2. That is a statement about demonstrated production usage and audit history, not about code quality — but it shifts assurance work onto us. Mitigating factors are real: MIT license, a recognized Laravel community maintainer, a recent release (October 2025), and a codebase small enough to vendor or fork within days. Two risks outrank the rest. First, environment isolation must be enforced, not advisory — a test key accepted in live is a customer-trust incident, and must be proven in source with an explicit negative test rather than inferred from the marketing copy. Second, the supplied documentation is self-contradictory: the repository positioning describes API token authentication, while the packaged description describes an invitation/onboarding system. Resolve which capability the released code actually delivers before scheduling any evaluation sprint; it determines what is even being assessed and it must not reach a roadmap or a customer commitment unresolved.
Key questions.
Stack fit. Best fit is a Laravel 10/11/12 API-first or API-plus-SPA application that must issue long-lived credentials to external consumers or internal services, and that needs per-key scopes plus test/live separation. Verify PHP and Laravel constraints against the actual runtime before committing. Poor fit where the only auth need is human login, where consumer mobile is the primary surface (Sanctum), or where OAuth2 grants are contractual.
Migration path. From Sanctum: schemas and semantics differ, so plan coexistence rather than conversion — issue Bastion keys alongside existing tokens, route by guard or key prefix, run both paths through a deprecation window (60–90 days for external consumers), then revoke legacy tokens on a published date. From nothing: adopt directly and skip the dual-path cost entirely. From Passport: only as part of an explicit decision to abandon OAuth2, which is a product decision, not a library choice.
Compatibility. Verify empirically, not by reading: (1) the guard and middleware do not collide with existing auth guards or auth:sanctum route groups; (2) migrations run cleanly on the target DB driver, including index and uniqueness assumptions on the key column; (3) scope enforcement composes with existing policies and gates instead of creating a second, divergent authorization layer that drifts from the first.
Sequencing.
Maintenance. Single-maintainer, small-footprint dependency with no vendor and no SLA. Pin the version exactly, schedule periodic source review rather than assuming passive safety, and treat a fork as a realistic contingency — the code is small enough that forking is days, not a quarter. Track releases manually; do not expect ecosystem pressure to surface breaking changes on your behalf. The 0.0.x version line argues for treating any upgrade as potentially breaking regardless of what the changelog states.
Support. Community-only. Nominate an internal owner for the token authentication surface and write the key lifecycle policy into our own runbooks, because the package will not supply it. Expect support volume to concentrate on customer-facing key management questions — where is my key, how do I rotate it, why is my test key failing in production — rather than on the library itself. Budget documentation as a deliverable with an owner, not an afterthought.
Scaling. One indexed lookup per authenticated request. With a proper index on the key hash, and a short-TTL cache of key-to-scope mappings if needed, this will not be the bottleneck; scope checks that trigger extra per-request queries on hot endpoints will be. Tens of thousands of keys are unremarkable; millions justify a caching layer and a design revisit.
Failure modes, ranked: environment isolation bypass — catastrophic to customer trust, so test it explicitly and negatively; auth table unavailability taking down all API traffic — confirm fail-closed behavior and mitigate with a read replica or cache; middleware applied to the wrong route group, leaving endpoints open or unusable; scope taxonomy drift producing over-permissive keys; maintainer abandonment with no internal fork capability; and a silent breaking change absorbed on upgrade.
Ramp-up. One engineer-day to a working spike for anyone with Sanctum experience; one to two engineer-weeks to a security-reviewed, production-shaped integration including the parallel-run strategy; two to four weeks of product and design effort for the customer-facing key management experience and scope taxonomy. Plan the policy work as the real cost and keep the dependency behind an internal auth interface so the implementation stays swappable and the exit remains cheap.
How can I help you explore Laravel packages today?