Auto-generate session secret; make SESSION_SECRET optional - #11
Merged
Merged
Conversation
Requiring users to generate and pass a SESSION_SECRET made the Docker setup harder than it needs to be. The key is now generated on first boot into $DATA_DIR/session-secret (0600) and reused afterwards; SESSION_SECRET still takes precedence so existing deployments keep their sessions.
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.
What does this change?
SESSION_SECRETis no longer required. When it's unset, a random 32-byte key is generated on first boot into$DATA_DIR/session-secret(/data/session-secretin Docker, mode0600) and reused on every later boot. This removes the one mandatory setup step, so a baredocker run/ compose paste works out of the box — the same approach most self-hosted apps take.app/lib/sessionSecret.server.tsresolves the key:SESSION_SECRETenv → existing file → generate + persist.server/app.tsno longer exits whenSESSION_SECRETis missing.docker-compose.ymluses${SESSION_SECRET:-}instead of:?(required)..env.example, AGENTS.md updated to describe the variable as optional.Reviewer notes
SESSION_SECRETis set, it wins, so existing deployments keep their current sessions after upgrading.database/anduploads/, which are the only paths a backup restore swaps — restoring doesn't sign the user out.:-default) or an empty file is treated as unset, never used as the key./datais a volume — already the documented setup.Related issue
None.
Checklist
npm run lint:fixandnpm run fmtat the repo rootapp/lib/sessionSecret.test.ts)npm run typecheckandnpm run buildpassCatalogProviderpatternfor new data sources, comments explain why not what)
Also verified manually: a production build booted with no
SESSION_SECRETgenerated the key file (-rw-------) and served/api/auth/me→{"authenticated":false,"needsSetup":true}.Screenshots
N/A — no UI change.