laranex/laravel-refresh-token
A Laravel package for adding refresh-token authentication to APIs, with secure token issuance, rotation, and revocation. Helps manage long-lived sessions without exposing access tokens, integrating with Laravel’s auth and database layers.
Architecture fit
laranex/laravel-refresh-token is a Sanctum-adjacent package that adds DB-backed refresh tokens with rotation on top of Laravel's token auth. That is a genuine architectural gap for teams shipping first-party SPAs or mobile clients: Sanctum's default personal access tokens are long-lived and non-rotating, and the alternatives (Passport/OAuth2, hand-rolled rotation) are either heavier or a security liability to build in-house. Fit is strongest for a Laravel monolith or modular monolith where the same DB already stores users and sessions. Fit is weak where auth is delegated to an external IdP (Auth0/Keycloak/Cognito) — this package would duplicate a solved problem.
Integration feasibility
Low surface area by design: Composer install, publish config and migrations, add a trait to the User model, protect routes with package middleware, and have clients call a refresh endpoint. A Laravel developer can get a working proof of concept in under a day. The real cost is not integration but client-side work — the consuming SPA/mobile app needs a 401 interceptor, single-flight refresh queueing, and secure refresh-token storage. Budget for that; it typically exceeds the backend effort.
Technical risk
The version under review is v4.0.0-alpha.8 — a pre-release, and the eighth alpha. That signals an unstable public API with no backward-compatibility guarantee between alphas, let alone from v3. Notably, the release notes for this build are effectively empty: no changelog body, no PR list, only a compare link. A TPM cannot assess breaking changes, deprecations, or security-relevant fixes from this artifact; the diff must be read directly. Secondary risks: security-critical code path (token issuance, rotation, revocation, reuse detection) maintained by a small OSS project with no commercial SLA; and a major-version bump that almost certainly renames namespaces, config keys, or the token table schema relative to v3.
Key questions
Stack fit Assumes Laravel with Eloquent and a relational DB (MySQL/Postgres); no Redis or queue dependency required for core operation. Front-end contract is a standard refresh-token flow, so React/Vue/React Native/Flutter clients all work with the usual interceptor pattern. If the product is server-rendered session auth only, this package adds no value.
Migration path
Do not move production to an alpha. Pin the current stable v3 line in composer.json, and evaluate v4 in a short-lived spike branch. If the v4 schema differs, treat forced global re-authentication (drop the token table, reissue on next login) as the default plan and only invest in a data migration if session continuity is a hard product requirement. Ship the upgrade behind a date-based rollout with a known re-login window.
Compatibility
Verify the Composer constraints against the exact Laravel/PHP/Sanctum versions in the app before anything else; alpha packages frequently bump minimum PHP or drop older Laravel majors. Because alphas are not API-stable, pin an exact alpha version (4.0.0-alpha.8, not ^4.0@alpha) if you proceed at all.
Sequencing
Maintenance Alpha cadence means frequent, sometimes breaking, upgrades; expect to re-read diffs rather than changelogs, since this release shipped no human-readable notes. Because the package owns a security-sensitive path, assign a named internal owner and consider vendoring or forking so upstream abandonment is not an incident.
Support No vendor SLA. Support is GitHub issues plus whatever the team can read from source. Escalation for auth bugs must be internal — define an on-call path for "users cannot log in" that does not depend on upstream responsiveness.
Scaling Each refresh is a DB write plus a read; at high request volume, index the token lookup column and run a scheduled prune of expired/revoked rows or the table grows unbounded. Put rate limiting on the refresh endpoint, and consider a short-lived cache for token validation if refresh traffic competes with primary reads.
Failure modes
Ramp-up Roughly half a day for a Laravel developer to integrate the happy path; one to two additional days to internalize rotation semantics, reuse detection, and the client-side refresh contract. A security review by someone fluent in OAuth 2.0 refresh-token best practices (rotation, reuse detection, hashed storage, revocation) should gate production use — and should be repeated at the v4 stable release, since this alpha's changes are undocumented.
How can I help you explore Laravel packages today?