Implement system-wide configuration management with encrypted storage for sensitive data:
Database:
- Migration 006: system_settings table with encryption support
- Migration 007: is_system_admin flag for users table
Services:
- settings.service.js: Configuration management with AES-256-GCM encryption
- getSetting, setSetting, deleteSetting
- Category-based organization
- Auto-encrypt/decrypt sensitive values
- Email configuration testing
Routes:
- settings.routes.js: 8 admin-only endpoints (CRUD settings, categories, test email)
Middleware:
- requireSystemAdmin: Verify system admin privileges (via SYSTEM_ADMIN_EMAILS env var or is_system_admin flag)
Default Settings:
- Email: SMTP configuration (host, port, credentials)
- Security: Email verification, password rules, lockout settings
- General: App name, support email, file size limits
Encryption:
- AES-256-GCM authenticated encryption
- Prevents tampering
- Per-setting encryption flag
- Secure key management via SETTINGS_ENCRYPTION_KEY env var
Environment:
- .env.example: Template for all required configuration
- Added SETTINGS_ENCRYPTION_KEY and SYSTEM_ADMIN_EMAILS
Production-ready admin configuration panel.
🤖 Generated with Claude Code
9 lines
367 B
SQL
9 lines
367 B
SQL
-- Migration: Add system admin flag to users
|
|
-- Date: 2025-10-21
|
|
-- Purpose: Allow marking users as system administrators
|
|
|
|
-- Add is_system_admin column (defaults to 0 / false)
|
|
ALTER TABLE users ADD COLUMN is_system_admin BOOLEAN DEFAULT 0;
|
|
|
|
-- Create index for faster system admin lookups
|
|
CREATE INDEX IF NOT EXISTS idx_users_system_admin ON users(is_system_admin);
|