[PR #6114] [MERGED] chore: update docu about auth secret #6455

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

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/6114
Author: @Paola3stefania
Created: 11/20/2025
Status: Merged
Merged: 12/1/2025
Merged by: @Bekacru

Base: canaryHead: chore/auth-secret-doc


📝 Commits (10+)

  • 721aed1 chore: update docu about auth secret
  • e54cf30 Merge branch 'canary' into chore/auth-secret-doc
  • fbecdde fix: jsut a warning
  • 903c562 Merge branch 'canary' into chore/auth-secret-doc
  • b3894c4 Merge branch 'canary' into chore/auth-secret-doc
  • 19a194f feat: secret validation
  • cbd7cd6 Merge remote-tracking branch 'upstream/canary' into chore/auth-secret-doc
  • 42ccd4f feat: throw error just in prod
  • 6cc7d95 Merge branch 'canary' into chore/auth-secret-doc
  • 03bf04a Merge branch 'canary' into chore/auth-secret-doc

📊 Changes

6 files changed (+200 additions, -35 deletions)

View changed files

📝 docs/content/docs/installation.mdx (+1 -1)
📝 packages/better-auth/src/context/__snapshots__/create-context.test.ts.snap (+2 -2)
📝 packages/better-auth/src/context/create-context.test.ts (+141 -23)
📝 packages/better-auth/src/context/create-context.ts (+54 -7)
📝 packages/better-auth/src/test-utils/test-instance.ts (+1 -1)
📝 packages/better-auth/src/utils/constants.ts (+1 -1)

📄 Description

This PR improves the Installation documentation by adding clear requirements for BETTER_AUTH_SECRET.
Several developers ran into cryptic runtime errors caused by using secrets that were too short or low-entropy.

This improves onboarding reliability, aligns with industry standards, and prevents common configuration mistakes.

Changes

•	Added a call-out under Installation → Set Environment Variables clarifying that:
•	BETTER_AUTH_SECRET must be 32+ characters
•	Should be generated using a high-entropy source (e.g., openssl rand -base64 32)
•	Short/weak secrets can lead to signing or encryption errors
image

Summary by cubic

Add runtime validation for BETTER_AUTH_SECRET and update installation docs with a clear callout on length and entropy. This enforces a 32+ char secret, rejects the default in production, and warns on low entropy.

  • New Features

    • Validate secret on startup: error if default used in production or <32 chars.
    • Warn when the secret appears low-entropy.
    • Updated tests and e2e fixtures to use a valid-length secret.
  • Migration

    • Set BETTER_AUTH_SECRET to a 32+ character random value; do not use the default in production.
    • Use the generator in the docs or run: npx @better-auth/cli secret.

Written for commit 66b6c9bf35. Summary will update automatically 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/6114 **Author:** [@Paola3stefania](https://github.com/Paola3stefania) **Created:** 11/20/2025 **Status:** ✅ Merged **Merged:** 12/1/2025 **Merged by:** [@Bekacru](https://github.com/Bekacru) **Base:** `canary` ← **Head:** `chore/auth-secret-doc` --- ### 📝 Commits (10+) - [`721aed1`](https://github.com/better-auth/better-auth/commit/721aed1996013e15370d81795311bf03ec4ed9f7) chore: update docu about auth secret - [`e54cf30`](https://github.com/better-auth/better-auth/commit/e54cf307a15bc1e6f3d28265d9a45d36ae4fa804) Merge branch 'canary' into chore/auth-secret-doc - [`fbecdde`](https://github.com/better-auth/better-auth/commit/fbecddef1e71463476af9462f1606d7c17ac2b2d) fix: jsut a warning - [`903c562`](https://github.com/better-auth/better-auth/commit/903c5622077d2c7710e88399a83f5046676df08e) Merge branch 'canary' into chore/auth-secret-doc - [`b3894c4`](https://github.com/better-auth/better-auth/commit/b3894c425e122047fd61fe53ebb0424dba0c78db) Merge branch 'canary' into chore/auth-secret-doc - [`19a194f`](https://github.com/better-auth/better-auth/commit/19a194fa939f01b681403c7d8722d3d144243da8) feat: secret validation - [`cbd7cd6`](https://github.com/better-auth/better-auth/commit/cbd7cd6ce120aea7e3afba3938c9b759780e59a9) Merge remote-tracking branch 'upstream/canary' into chore/auth-secret-doc - [`42ccd4f`](https://github.com/better-auth/better-auth/commit/42ccd4f58e9c4e5756f2ff5b63be4c51b8a74e62) feat: throw error just in prod - [`6cc7d95`](https://github.com/better-auth/better-auth/commit/6cc7d95f416c4c7a303e039629d36cdee38c1b71) Merge branch 'canary' into chore/auth-secret-doc - [`03bf04a`](https://github.com/better-auth/better-auth/commit/03bf04a93acf96d0ac764d2f867d543dd9051520) Merge branch 'canary' into chore/auth-secret-doc ### 📊 Changes **6 files changed** (+200 additions, -35 deletions) <details> <summary>View changed files</summary> 📝 `docs/content/docs/installation.mdx` (+1 -1) 📝 `packages/better-auth/src/context/__snapshots__/create-context.test.ts.snap` (+2 -2) 📝 `packages/better-auth/src/context/create-context.test.ts` (+141 -23) 📝 `packages/better-auth/src/context/create-context.ts` (+54 -7) 📝 `packages/better-auth/src/test-utils/test-instance.ts` (+1 -1) 📝 `packages/better-auth/src/utils/constants.ts` (+1 -1) </details> ### 📄 Description This PR improves the Installation documentation by adding clear requirements for BETTER_AUTH_SECRET. Several developers ran into cryptic runtime errors caused by using secrets that were too short or low-entropy. This improves onboarding reliability, aligns with industry standards, and prevents common configuration mistakes. **Changes** • Added a call-out under Installation → Set Environment Variables clarifying that: • BETTER_AUTH_SECRET must be 32+ characters • Should be generated using a high-entropy source (e.g., openssl rand -base64 32) • Short/weak secrets can lead to signing or encryption errors <img width="837" height="774" alt="image" src="https://github.com/user-attachments/assets/84a18472-1201-4d34-a6f8-489b09f3d055" /> <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Add runtime validation for BETTER_AUTH_SECRET and update installation docs with a clear callout on length and entropy. This enforces a 32+ char secret, rejects the default in production, and warns on low entropy. - **New Features** - Validate secret on startup: error if default used in production or <32 chars. - Warn when the secret appears low-entropy. - Updated tests and e2e fixtures to use a valid-length secret. - **Migration** - Set BETTER_AUTH_SECRET to a 32+ character random value; do not use the default in production. - Use the generator in the docs or run: npx @better-auth/cli secret. <sup>Written for commit 66b6c9bf3516ac03b07323a824af69bbb932ba8a. Summary will update automatically 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 12:59: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#6455