feat: Add LOCKBOX_MASTER_KEY rotation script with interactive key input #14662
+781
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: https://github.com/ToolJet/tj-ee/issues/3808
Docs: docs: LOCKBOX_MASTER_KEY rotation script #14856
Summary
Adds a key rotation script to securely rotate the
LOCKBOX_MASTER_KEYused for encrypting sensitive data in the database. The script uses an interactive prompt for the old key, ensuring a clean and secureworkflow without storing multiple keys in environment variables.
Changes
New Files
server/scripts/services/rotation.service.ts- DualKeyEncryptionService for handling two encryption keys simultaneously during rotationserver/scripts/rotate-lockbox-key.ts- Main rotation script with transaction safety, dry-run mode, and verificationModified Files
server/package.json- Addedrotate:keysandrotate:keys:prodnpm scriptspackage.json- Added root-level wrapper scripts for key rotationFeatures
🔐 Secure Rotation Process
Rotates encryption keys for all 5 encrypted tables:
credentials(value_ciphertext)org_environment_constant_values(value)sso_configs(configs with secret fields)organization_tjdb_configurations(pg_password)user_details(user_metadata)✅ Safety Features
dbTransactionWrapor rolled back on failure--dry-runflag)Usage
1. Update Environment Variable
QA Checklist