Closes #563
- Production Startup Guard: Modified the shared environment validation schema so that if the application starts up in a production environment (
NODE_ENV === "production"), it refuses to boot and fails fast with a clear error message ifJWT_SECRETis missing, set to a known development default, or is too weak. - Development/Test Compatibility: Maintained compatibility for development and test environments so they can still boot and run test suites using simple or default keys.
- JWT Strength Checks: Implemented security requirements in production for
JWT_SECRET:- Must not be one of the known development secrets (e.g.,
super-secret-development-key-please-change,change-me-to-a-long-random-secret-before-production). - Must not contain development placeholders (like
change-me,please-change, ordevelopment). - Must contain at least 8 unique characters (preventing simple repeated patterns like
a.repeat(32)). - Must contain a mix of uppercase letters, lowercase letters, and digits or special characters.
- Must not be one of the known development secrets (e.g.,
- Unit Tests: Added 6 tests to
shared/validation/validateEnv.test.tsto assert all validation rules across environments.
Shared Libraries:
- index.ts — replaced
EnvSchema.refinewithEnvSchema.superRefineincorporating the production environment check, default block list, placeholder checks, and complexity strength validator. - validateEnv.test.ts — added unit tests for production vs non-production validation behavior.
- ✅ Validation allows defaults/simple keys in
developmentandtestenvironments - ✅ Validation fails in
productionfor default/known development secrets - ✅ Validation fails in
productionfor placeholder-containing secrets - ✅ Validation fails in
productionfor secrets lacking 8 unique characters - ✅ Validation fails in
productionfor secrets lacking lowercase/uppercase/digits/special characters mix - ✅ Validation succeeds in
productionfor a strong, complex secret