feat: load root env and encrypt persisted secrets#8
Merged
Conversation
feat: require app key and encrypt persisted secrets
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates server configuration loading to better support monorepo development, and introduces an APP_KEY-based mechanism to encrypt persisted provider credentials (plus hashed lookup for provider access tokens).
Changes:
- Add a custom env loader to read the repo-root
.env(and cwd.env) and resolve relativeCLIPARR_DATA_DIRconsistently. - Require
APP_KEYand encrypt/decrypt persisted secrets in SQLite (including addingaccess_token_hashfor deterministic token lookups). - Update Docker/Compose configuration, ignore rules, and documentation to reflect the new env requirements and data-dir behavior.
Reviewed changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| docker-compose.yml | Requires APP_KEY at compose runtime. |
| apps/server/src/session/store.ts | Encrypts/decrypts persisted session token/resource fields. |
| apps/server/src/server.ts | Switches to the new env loader and adds startup error handling. |
| apps/server/src/security/secrets.ts | Adds encryption/hash utilities keyed by APP_KEY. |
| apps/server/src/db/schema.ts | Adds accessTokenHash column and updates unique index. |
| apps/server/src/db/providerAccountsRepository.ts | Encrypts access tokens, hashes for lookup, adds legacy fallback lookup. |
| apps/server/src/db/migrations.ts | Adds migration for access_token_hash and index changes. |
| apps/server/src/db/mediaSourcesRepository.ts | Encrypts/decrypts JSON credential/connection fields. |
| apps/server/src/db/database.ts | Resolves data dir via env loader and enforces APP_KEY before DB init. |
| apps/server/src/config/loadEnv.ts | Loads root + cwd .env and resolves relative CLIPARR_DATA_DIR. |
| apps/server/drizzle.config.ts | Uses env loader and consistent data-dir resolution for Drizzle. |
| README.md | Documents APP_KEY requirement for Docker usage. |
| CONTRIBUTING.md | Adds setup guidance for .env + APP_KEY. |
| .gitignore | Ignores nested apps/server/.cliparr-data. |
| .env.example | Adds APP_KEY to example env file. |
| .dockerignore | Excludes nested apps/server/.cliparr-data from Docker builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Notes
Testing