[PR #7320] [CLOSED] docs: add warning that enableSessionForAPIKeys creates mock sessions #7225

Closed
opened 2026-03-13 13:28:55 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/7320
Author: @Bekacru
Created: 1/13/2026
Status: Closed

Base: canaryHead: claude/slack-docs-enable-session-api-keys-warning-V74TC


📝 Commits (1)

  • cf56e27 docs: add warning that enableSessionForAPIKeys creates mock sessions

📊 Changes

2 files changed (+57 additions, -5 deletions)

View changed files

📝 docs/content/docs/plugins/api-key.mdx (+42 -3)
📝 packages/better-auth/src/plugins/api-key/types.ts (+15 -2)

📄 Description

Clarify that enableSessionForAPIKeys creates mock sessions (not real database-stored sessions) with important limitations:

  • Mock sessions don't include dynamically computed properties
  • Admin plugin's adminUserIds won't set role to admin in mock sessions
  • Plugin hooks may not fire as expected
  • Security risk if API key is leaked

Added detailed documentation explaining how mock sessions work, their limitations, and guidance on when to use this feature vs alternatives.

Closes #7312


Summary by cubic

Docs and types now warn that enableSessionForAPIKeys creates mock in-memory sessions (not real database sessions) and explain when to avoid it in favor of verifyApiKey, addressing #7312. The limits include no dynamic properties (e.g., adminUserIds roles), plugin hooks may not run, and leaked keys can impersonate users.

Written for commit cf56e27a5d. 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/7320 **Author:** [@Bekacru](https://github.com/Bekacru) **Created:** 1/13/2026 **Status:** ❌ Closed **Base:** `canary` ← **Head:** `claude/slack-docs-enable-session-api-keys-warning-V74TC` --- ### 📝 Commits (1) - [`cf56e27`](https://github.com/better-auth/better-auth/commit/cf56e27a5de50568bd26af9cd61dffc0d98422bb) docs: add warning that enableSessionForAPIKeys creates mock sessions ### 📊 Changes **2 files changed** (+57 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/plugins/api-key.mdx` (+42 -3) 📝 `packages/better-auth/src/plugins/api-key/types.ts` (+15 -2) </details> ### 📄 Description Clarify that enableSessionForAPIKeys creates mock sessions (not real database-stored sessions) with important limitations: - Mock sessions don't include dynamically computed properties - Admin plugin's adminUserIds won't set role to admin in mock sessions - Plugin hooks may not fire as expected - Security risk if API key is leaked Added detailed documentation explaining how mock sessions work, their limitations, and guidance on when to use this feature vs alternatives. Closes #7312 <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Docs and types now warn that enableSessionForAPIKeys creates mock in-memory sessions (not real database sessions) and explain when to avoid it in favor of verifyApiKey, addressing #7312. The limits include no dynamic properties (e.g., adminUserIds roles), plugin hooks may not run, and leaked keys can impersonate users. <sup>Written for commit cf56e27a5de50568bd26af9cd61dffc0d98422bb. 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-03-13 13:28:55 -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#7225