Lane cf66219986
fix: configurable JWT TTL with working refresh endpoint (#800) (#801)
* fix: configurable JWT TTL with working refresh endpoint (#800)

Replace the hardcoded 24h JWT expiration with configurable TTL (default 30d)
resolvable via JWT_EXPIRES_IN env var (ceiling) or admin Settings → Security
UI. Rewrite /auth/refresh to accept valid-or-recently-expired tokens within a
configurable grace window (default 7d), re-verifying the HS256 signature via
Web Crypto (since hono/jwt checks exp before signature) and re-validating the
user against the database before issuing a fresh token.

Updates every token-minting call site (auth routes, OTP plugin, magic-link
plugin, OAuth providers) to read the TTL from the DB-aware helper. Adds a
live Session / JWT card to Admin → Settings → Security with save/load and
matching persistence via SettingsService. Updates repo docs and the doc site
authentication page to describe the new configuration surface and refresh
semantics.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* fix: keep /auth/refresh 401 message and flex cookie Max-Age assertion

- Restore "Authentication required" as the error message when /auth/refresh is
  called without a token, matching the prior behavior the E2E contract expects.
- Update the cookie E2E to assert Max-Age is present (any positive value)
  instead of the old hardcoded 86400, since JWT TTL is now configurable.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-21 18:42:51 -07:00
..
2025-11-25 12:41:59 -08:00