[PR #8894] [MERGED] fix(oauth-provider): enforce DB-backed sessions with secondary storage #16531

Closed
opened 2026-04-13 10:33:44 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8894
Author: @GautamBytes
Created: 4/1/2026
Status: Merged
Merged: 4/2/2026
Merged by: @ping-maxwell

Base: mainHead: fix/adapter-redis-schema


📝 Commits (1)

  • 6fee32c fix oauth-provider secondary storage guard

📊 Changes

2 files changed (+81 additions, -2 deletions)

View changed files

📝 packages/oauth-provider/src/oauth.test.ts (+75 -0)
📝 packages/oauth-provider/src/oauth.ts (+6 -2)

📄 Description

Summary

This change makes oauth-provider fail fast when it is used with secondaryStorage without also enabling database-backed sessions.

oauth-provider performs adapter-level session lookups by session id, so session.storeSessionInDatabase must be explicitly set to true when secondaryStorage is enabled. Previously, that requirement was only enforced when a session config object was present, which allowed unsupported configs to slip through initialization and fail later at runtime.

Closes #8893

Changes

  • enforce the existing session.storeSessionInDatabase: true requirement whenever secondaryStorage is enabled
  • keep getAuthTables() behavior unchanged
  • add regression tests for:
    • secondaryStorage with no session config
    • secondaryStorage with storeSessionInDatabase: false
    • secondaryStorage with storeSessionInDatabase: true

Summary by cubic

Enforces DB-backed sessions when secondaryStorage is enabled in oauth-provider to prevent unsupported configs from failing at runtime. Adds an init-time error and regression tests to cover the key scenarios.

  • Bug Fixes

    • Fail fast if secondaryStorage is set and session.storeSessionInDatabase is not true.
    • Added tests for omitted session config, storeSessionInDatabase: false, and true.
  • Migration

    • If you use secondaryStorage, set session.storeSessionInDatabase: true.

Written for commit 6fee32c142. Summary will update on new commits.


🔄 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/8894 **Author:** [@GautamBytes](https://github.com/GautamBytes) **Created:** 4/1/2026 **Status:** ✅ Merged **Merged:** 4/2/2026 **Merged by:** [@ping-maxwell](https://github.com/ping-maxwell) **Base:** `main` ← **Head:** `fix/adapter-redis-schema` --- ### 📝 Commits (1) - [`6fee32c`](https://github.com/better-auth/better-auth/commit/6fee32c142102809a8b99c2ee4bbaa421204e94a) fix oauth-provider secondary storage guard ### 📊 Changes **2 files changed** (+81 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `packages/oauth-provider/src/oauth.test.ts` (+75 -0) 📝 `packages/oauth-provider/src/oauth.ts` (+6 -2) </details> ### 📄 Description ## Summary This change makes `oauth-provider` fail fast when it is used with `secondaryStorage` without also enabling database-backed sessions. `oauth-provider` performs adapter-level session lookups by session id, so `session.storeSessionInDatabase` must be explicitly set to `true` when `secondaryStorage` is enabled. Previously, that requirement was only enforced when a `session` config object was present, which allowed unsupported configs to slip through initialization and fail later at runtime. ## Closes #8893 ## Changes - enforce the existing `session.storeSessionInDatabase: true` requirement whenever `secondaryStorage` is enabled - keep `getAuthTables()` behavior unchanged - add regression tests for: - `secondaryStorage` with no `session` config - `secondaryStorage` with `storeSessionInDatabase: false` - `secondaryStorage` with `storeSessionInDatabase: true` <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Enforces DB-backed sessions when `secondaryStorage` is enabled in `oauth-provider` to prevent unsupported configs from failing at runtime. Adds an init-time error and regression tests to cover the key scenarios. - **Bug Fixes** - Fail fast if `secondaryStorage` is set and `session.storeSessionInDatabase` is not true. - Added tests for omitted session config, `storeSessionInDatabase: false`, and `true`. - **Migration** - If you use `secondaryStorage`, set `session.storeSessionInDatabase: true`. <sup>Written for commit 6fee32c142102809a8b99c2ee4bbaa421204e94a. Summary will update on new commits.</sup> <!-- End of auto-generated description by cubic. --> --- <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-13 10:33:44 -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#16531