LibreChat/api
Danny Avila 3c844c9cc6
🥠 refactor: Always set OIDC refresh token cookie to survive session expiry (#11810)
The express session cookie maxAge (SESSION_EXPIRY, default 15 min) is
shorter than the OIDC token lifetime (~1 hour). When OPENID_REUSE_TOKENS
is enabled, the refresh token was stored only in the express session
(req.session.openidTokens). After the session expired, the refresh token
was lost, causing "Refresh token not provided" on the next refresh
attempt and signing the user out. Re-login via OIDC would succeed
immediately (provider session still active), masking the root cause.

The session-only storage was introduced in #11236 to avoid HTTP/2 header
size limits from large access_token/id_token JWTs (especially Azure
Entra ID with many group claims). The refresh token is a small opaque
string and does not contribute to that problem.

Move the refreshToken cookie out of the no-session fallback branch so it
is always set alongside the session storage. The refreshController
already has the fallback logic (req.session?.openidTokens?.refreshToken
|| parsedCookies.refreshToken) but previously never had a cookie to fall
back to.

Timeline before fix:
  T=0      Login, session created (15 min maxAge), id_token valid ~1 hr
  T=15min  Session cookie expires, refresh token lost
  T=15min+ Page refresh or id_token expiry triggers refresh, fails with
           "Refresh token not provided", user redirected to /login

Timeline after fix:
  T=0      Login, session created + refreshToken cookie (7 day expiry)
  T=15min  Session cookie expires
  T=15min+ Refresh reads refreshToken from cookie fallback, succeeds,
           restores session with fresh tokens
2026-02-16 14:42:19 -05:00
..
app 🧩 refactor: Tool Context Builders for Web Search & Image Gen (#11644) 2026-02-05 14:10:19 +01:00
cache 🪙 refactor: Distinguish ID Tokens from Access Tokens in OIDC Federated Auth (#11711) 2026-02-13 11:07:39 -05:00
config 🪵 fix: Standardize Logging Directory with Environment-Aware Resolution (#11000) 2025-12-16 18:00:06 -05:00
db 🔎 fix: Include Legacy Documents With Undefined _meiliIndex in Search Sync (#11745) 2026-02-12 18:05:53 -05:00
models 👻 fix: Prevent Async Title Generation From Recreating Deleted Conversations (#11797) 2026-02-14 13:57:00 -05:00
server 🥠 refactor: Always set OIDC refresh token cookie to survive session expiry (#11810) 2026-02-16 14:42:19 -05:00
strategies 🪙 refactor: Distinguish ID Tokens from Access Tokens in OIDC Federated Auth (#11711) 2026-02-13 11:07:39 -05:00
test 💾 feat: Add Memory Configuration Options for CI unit tests (#10567) 2025-12-25 16:17:17 -05:00
utils 🤖 feat: Claude Opus 4.6 - 1M Context, Premium Pricing, Adaptive Thinking (#11670) 2026-02-06 18:35:36 -05:00
jest.config.js 🪦 refactor: Remove Legacy Code (#10533) 2025-12-11 16:36:12 -05:00
jsconfig.json feat(api): initial Redis support; fix(SearchBar): proper debounce (#1039) 2023-10-11 17:05:47 -04:00
package.json 📦 chore: @librechat/agents to v3.1.43 (#11805) 2026-02-15 21:35:32 -05:00
typedefs.js 🪦 refactor: Remove Legacy Code (#10533) 2025-12-11 16:36:12 -05:00