mirror of
https://github.com/willchen96/mike.git
synced 2026-06-14 20:55:13 +02:00
Merge pull request #21 from Metbcy/fix/download-secret-fail-fast
fix(security): fail fast when download HMAC secret is missing (closes #7)
This commit is contained in:
commit
0ac2744a8e
2 changed files with 14 additions and 4 deletions
|
|
@ -10,11 +10,16 @@ import crypto from "crypto";
|
|||
*/
|
||||
|
||||
function getSecret(): string {
|
||||
return (
|
||||
const secret =
|
||||
process.env.DOWNLOAD_SIGNING_SECRET ??
|
||||
process.env.SUPABASE_SECRET_KEY ??
|
||||
"dev-secret"
|
||||
);
|
||||
process.env.SUPABASE_SECRET_KEY;
|
||||
if (!secret) {
|
||||
throw new Error(
|
||||
"DOWNLOAD_SIGNING_SECRET (or SUPABASE_SECRET_KEY as a fallback) must be set. " +
|
||||
"Generate a strong random value (e.g. `openssl rand -hex 32`) and set it in the environment.",
|
||||
);
|
||||
}
|
||||
return secret;
|
||||
}
|
||||
|
||||
function b64urlEncode(buf: Buffer): string {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue