fix(security): complete full security remediation - httpOnly cookies, CsrfGuard, nonce-based CSP, and strict JWT production validation
Deploy Canina / deploy (push) Successful in 32s
E2E Playwright Tests / Run Full E2E & Security Suites (push) Failing after 6s

This commit is contained in:
parsa committed 2026-09-24 00:29:46 +03:30
1 parent 8a3adacd38
commit abc957ba75
8 files changed
+352 -34

No files matched your search

+15 -2
View File
@@ -52,15 +52,28 @@ export function validateEnv(config: Record<string, unknown>) {
throw new Error(`Environment Validation Error: ${messages}`);
}
const isProduction = validatedConfig.NODE_ENV === 'production';
if (!validatedConfig.JWT_ACCESS_SECRET) {
if (isProduction && !process.env.JWT_SECRET) {
throw new Error(
'Environment Validation Error: JWT_ACCESS_SECRET is strictly required in production mode.',
);
}
process.env.JWT_ACCESS_SECRET =
process.env.JWT_SECRET ||
'canina_secure_access_token_jwt_secret_production_2026';
'canina_dev_access_token_jwt_secret_development_only';
validatedConfig.JWT_ACCESS_SECRET = process.env.JWT_ACCESS_SECRET;
}
if (!validatedConfig.JWT_REFRESH_SECRET) {
if (isProduction) {
throw new Error(
'Environment Validation Error: JWT_REFRESH_SECRET is strictly required in production mode.',
);
}
process.env.JWT_REFRESH_SECRET =
'canina_secure_refresh_token_jwt_secret_production_2026';
'canina_dev_refresh_token_jwt_secret_development_only';
validatedConfig.JWT_REFRESH_SECRET = process.env.JWT_REFRESH_SECRET;
}