[PR #8708] [MERGED] fix: prevent revoked sessions from being restored via database fallback #25061

Closed
opened 2026-04-15 22:42:38 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8708
Author: @bytaesu
Created: 3/20/2026
Status: Merged
Merged: 3/20/2026
Merged by: @himself65

Base: canaryHead: 2026-03-20/fix/secondary-storage-revoked-session-fallback


📝 Commits (4)

  • f47e4f1 fix: prevent revoked sessions from being restored via database fallback
  • ecf4387 chore: update comment
  • 2ca833b fix: update if condition
  • 1b903d9 test: add cases for storeSessionInDatabase option

📊 Changes

2 files changed (+116 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/db/internal-adapter.ts (+8 -1)
📝 packages/better-auth/src/db/secondary-storage.test.ts (+108 -0)

📄 Description

Note

preserveSessionInDatabase is intended for tracking, not authentication.

docs

https://better-auth.com/docs/concepts/session-management#preserving-sessions

When both preserveSessionInDatabase and storeSessionInDatabase are enabled, falling back to the database when a session is missing in secondary storage is not appropriate. It may improve resilience if secondary storage is down, but it goes beyond its intended purpose.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/8708 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 3/20/2026 **Status:** ✅ Merged **Merged:** 3/20/2026 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `2026-03-20/fix/secondary-storage-revoked-session-fallback` --- ### 📝 Commits (4) - [`f47e4f1`](https://github.com/better-auth/better-auth/commit/f47e4f1f7bdca21d3ae32e7be3c38cee19c4f0e3) fix: prevent revoked sessions from being restored via database fallback - [`ecf4387`](https://github.com/better-auth/better-auth/commit/ecf438776c524e41c66784ee0dc6c225d9b633ad) chore: update comment - [`2ca833b`](https://github.com/better-auth/better-auth/commit/2ca833b89013f5edfd9104d21216eb6aa5e49321) fix: update if condition - [`1b903d9`](https://github.com/better-auth/better-auth/commit/1b903d95d166b9ae7d67b48bcd8dc4b1eede5796) test: add cases for storeSessionInDatabase option ### 📊 Changes **2 files changed** (+116 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/db/internal-adapter.ts` (+8 -1) 📝 `packages/better-auth/src/db/secondary-storage.test.ts` (+108 -0) </details> ### 📄 Description > [!NOTE] > ### `preserveSessionInDatabase` is intended for tracking, not authentication. > > <img width="913" height="447" alt="docs" src="https://github.com/user-attachments/assets/9df1801c-c751-406f-82ac-87c007db6b62" /> > > https://better-auth.com/docs/concepts/session-management#preserving-sessions When both `preserveSessionInDatabase` and `storeSessionInDatabase` are enabled, falling back to the database when a session is missing in secondary storage is not appropriate. It may improve resilience if secondary storage is down, but it goes beyond its intended purpose. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-15 22:42:38 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#25061