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 Refresh Token Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

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

  • Which Laravel, PHP, and Sanctum versions are supported, and is Sanctum optional or required?
  • What actually changed between v3 and v4, and between alpha.7 and alpha.8? (Requires reading the diff — release notes do not say.)
  • Are refresh tokens hashed at rest, and is reuse detection implemented with a grace window for concurrent requests?
  • Does it coexist with Sanctum's existing token abilities/scopes, or replace them?
  • What is the migration story for the token table from v3, and is forced re-authentication of all users acceptable?
  • Test coverage, CI matrix, and any security policy / CVE history?
  • License terms and maintainer count / bus factor?

Integration Approach

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

  1. Read the alpha.7→alpha.8 diff and the v3→v4 diff; write down the breaking changes yourself.
  2. Spike branch: install, publish config/migrations, wire the trait and middleware.
  3. Contract tests on login/refresh/revoke, including concurrent-refresh and reuse-detection cases.
  4. Staging load test of the refresh endpoint with realistic token lifetimes.
  5. Canary at a small percentage of traffic, with auth error rate and re-login rate as the rollback triggers.
  6. Full rollout only after v4 reaches a stable (non-alpha/beta) tag.

Operational Impact

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

  • Concurrent refresh from multiple tabs/devices invalidating each other → user-visible logout loops; needs a reuse grace window or client-side single-flight.
  • Clock skew between app servers shortening effective token lifetime.
  • Reuse-detection false positives mass-revoking sessions.
  • Failed migration or misconfigured middleware locking every user out at once (blast radius = 100% of authenticated traffic).
  • Silent upstream behavior change in an alpha bump, with no changelog to warn you.

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.

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.
robertmarney/lara-hierarchial-collections
simonschaufi/rule-doc-generator
emissaoja/emissaoja
blackbricksoftware/gravityforms-civicrm-form-processor
al-rahabi/fancy-crud
jinas/dhivatar-component
mltstephane/laravel-quality
bernskiold/laravel-talentlms
bernskioldmedia/laravel-form-architect
youbar/easy-crud
c-point-labs/laravel-hostyourai
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo