Database Configuration
Database connection string for PostgreSQL. Used by Prisma to connect to the database where encryption keys are stored.Example:
Encryption Key Configuration
Number of days before encryption keys expire and need rotation. Keys are automatically marked as expired after this period.Implementation: Behavior:
src/encryption/encryption.service.ts:24-27- Keys are generated with an expiration date set to current date + rotation days
- Expired keys are marked as deprecated by the daily cron job
- Clients are automatically issued existing valid keys if available
Number of days to retain deprecated encryption keys before permanent deletion. This provides a grace period for decrypting old data.Implementation: Behavior:
src/tasks/key-rotation.tasks.ts:18-21- Deprecated keys are kept for the retention period
- Keys older than retention days are permanently deleted by the daily cron job
- Ensures old encrypted data can still be decrypted during the retention window
Data Validation Configuration
Maximum allowed size in bytes for encrypted data payloads. Requests exceeding this limit are rejected.Implementation: Validation: Error Response:
src/encryption/encryption.service.ts:28-31src/encryption/encryption.service.ts:215-222- Status: 500
- Message: “Failed to decrypt data”
- Logged: Warning with actual size vs limit
Configuration Example
Create a.env file in your project root:
Key Lifecycle Example
Related Documentation
- Rate Limits - Key generation rate limiting
- Key Rotation - Automated key rotation process