Repository navigation
fix(auth): keep the JWT signing key in a dedicated volume - #149
Merged
Merged
Conversation
The server wrote jwt.key to the executable's directory, /app in the image, so it lived in the container's writable layer and every container rebuild generated a new key and signed all users out. - ARTEX_JWT_KEY_DIR selects the key directory (default: config.BaseDir(), unchanged for non-Docker installs). docker-compose.yml sets it to /app/keys and bind-mounts ./keys there; the Dockerfile declares the volume. The key stays out of data/, which the file manager browses. - loadOrCreateJWTKey creates the directory (0700). When keyDir/jwt.key is missing it migrates dataDir/jwt.key, then BaseDir()/jwt.key (mode 0600, old file removed), otherwise generates a new key. An existing key is never overwritten; a short one is now a startup error. - .gitignore and .dockerignore exclude keys/. - README and CHANGELOG updated; the 0.5.0 known issue is removed.
Merged
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.
Summary
The JWT signing key was written next to the executable (
/appin the image), which lives in the container's writable layer. Every container rebuild generated a new key and signed all users out.This PR keeps the key out of
data/(the file manager root, see df50c28) and stores it in a dedicated volume.ARTEX_JWT_KEY_DIRselects the key directory. Default is the base dir, so non-Docker installs are unchanged../keys:/app/keys,ARTEX_JWT_KEY_DIR=/app/keys,VOLUMEdeclared in the Dockerfile.data/jwt.key, then from the base dir. An existing key is never overwritten. A key shorter than 32 bytes is now a startup error.Upgrade (Docker)
One-time logout. Before recreating the container, copy the current key out:
Without this step, a new key is generated and users must log in again.
Testing
go build ./...,go vet, gofmt on changed files: clean.go test ./server -run TestLoadOrCreateJWTKey: migration from data dir and base dir, generation, no overwrite.Notes