Add docker-compose deploy path with Coolify-managed secrets
Adds docker-compose.yml so Coolify can provision Postgres and generate DATABASE_URL/SESSION_SECRET/TOKEN_ENCRYPTION_KEY/CRON_SECRET itself via its SERVICE_PASSWORD_* magic variables, instead of an operator typing them into the dashboard by hand. TOKEN_ENCRYPTION_KEY now derives its AES-256 key via SHA-256 instead of requiring exactly 32 raw bytes in base64, so a generated magic variable works regardless of its format. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,12 +5,13 @@ import crypto from "node:crypto";
|
||||
// yielding a garbage token.
|
||||
const VERSION = "v1";
|
||||
|
||||
// Derived via SHA-256 (always 32 bytes) rather than requiring the operator to
|
||||
// supply exactly 32 raw bytes in base64 — any sufficiently random string works,
|
||||
// including one a host platform (e.g. Coolify's SERVICE_PASSWORD_64_*) generates.
|
||||
function key(): Buffer {
|
||||
const raw = process.env.TOKEN_ENCRYPTION_KEY;
|
||||
if (!raw) throw new Error("TOKEN_ENCRYPTION_KEY env var is not set");
|
||||
const buf = Buffer.from(raw, "base64");
|
||||
if (buf.length !== 32) throw new Error("TOKEN_ENCRYPTION_KEY must be 32 bytes (base64)");
|
||||
return buf;
|
||||
return crypto.createHash("sha256").update(raw).digest();
|
||||
}
|
||||
|
||||
export function encryptToken(plain: string): string {
|
||||
|
||||
Reference in New Issue
Block a user