Repository navigation
Accept versioned Better Auth secrets - #449
Merged
Merged
Conversation
BETTER_AUTH_SECRET was the only key for Better Auth's encrypted values, such as provider tokens and the JWT signing key, and had no version, so it could not be replaced. BETTER_AUTH_SECRETS passes Better Auth's own version list, current first. New values carry the version; values written before still open with BETTER_AUTH_SECRET. Hosted deployments require it.
Whitespace around versions and secrets is ignored as Better Auth's own parser ignores it, an empty setting counts as unset, and duplicate or unsafe version numbers fail configuration instead of authentication startup, so deploy-hosted stops before it changes anything. Compose passes the setting to the control plane, and deploy logs redact each version on its own. The test opens a value under an earlier version after rotation.
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
widefleet-docs | 65ad6e1 | Nov 27 2026, 11:13 AM |
Better Auth treats only an empty value as unset and reads the variable itself when the option is unset, so a blank value passed configuration but failed authentication startup after a Hosted deployment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
BETTER_AUTH_SECRETis the only key for the values Better Auth encrypts, such as provider tokens inaccount, the private JWT signing key injwksand OAuth replay responses. Its ciphertexts name no version, so the secret could not be replaced without losing them.Changes
BETTER_AUTH_SECRETStakes Better Auth's version list, current first, as comma-separated<version>:<secret>entries, read as Better Auth reads them (surrounding whitespace ignored; an empty value counts as unset). Secrets need 32 or more characters, and duplicate or unsafe version numbers fail configuration, sodeploy-hostedstops before it changes anything. The control plane passes the list as Better Auth'ssecretsoption.BETTER_AUTH_SECRETstays and remains Better Auth's fallback, so values written before versions still open. New values carry their version ($ba$<version>$).deploy-hostedrequiresBETTER_AUTH_SECRETS, validates it with the rest of the configuration, deploys it to the control plane and redacts each version in its logs.BETTER_AUTH_SECRETSto the control plane. Without it, installations keep the single authentication key; with it, the earliest version must hold that key.Upgrade
BETTER_AUTH_SECRETSto1:followed by the currentBETTER_AUTH_SECRET, which must contain no comma and no surrounding whitespace. Nothing changes for signed-in users.Retiring a version later still needs more: the JWT signing key and provider tokens of inactive users are not written again, and signed session cookies follow the current version only. That is a separate change.
Testing
svelte-check(control plane),oxlint,oxfmtapps/control-plane:better-auth-secrets.test.ts(values from before versions and under an earlier version open after rotation, new values carry the current version, entries parse as Better Auth parses them, malformed lists are rejected; fails without the option),social-sign-in.test.ts