fix(auth): require admin auth for backup and translator routes

Protect database backup, export, restore, and translator save endpoints
with authentication checks to block unauthenticated data access and
state changes.

Also remove the insecure API key secret fallback, ignore nested app env
files from package publishes, and align tests with explicit
application/json Accept headers for non-stream requests
This commit is contained in:
diegosouzapw
2026-04-12 19:08:06 -03:00
parent b65caf82b4
commit c286fdc96a
9 changed files with 51 additions and 15 deletions

View File

@@ -6,9 +6,12 @@ if (!process.env.API_KEY_SECRET) {
}
function getApiKeySecret(): string {
const secret = process.env.API_KEY_SECRET || "omniroute-default-insecure-api-key-secret";
const secret = process.env.API_KEY_SECRET;
if (!secret || secret.trim() === "") {
throw new Error("API_KEY_SECRET is required for API key CRC operations");
throw new Error(
"API_KEY_SECRET is required for API key CRC operations. " +
"The startup validator (instrumentation-node.ts) should have set this automatically."
);
}
return secret;
}