Secrets Management
Secrets Management
Section titled “Secrets Management”This document explains how secrets and credentials are managed in the Merq platform.
Overview
Section titled “Overview”| Method | Status | Description |
|---|---|---|
| Environment Variables | ✅ Current | Main configuration method |
| Docker Secrets | 🔵 Planned | For Docker Swarm |
| Kubernetes Secrets | 🔵 Planned | For K8s deployments |
| HashiCorp Vault | 🔵 Future | Enterprise secret management |
Environment Variables
Section titled “Environment Variables”Required Variables
Section titled “Required Variables”| Variable | Description | Example |
|---|---|---|
DB_HOST | PostgreSQL host | localhost |
DB_PORT | PostgreSQL port | 5432 |
DB_USER | Database username | merq |
DB_PASSWORD | Database password | secure-password |
DB_NAME | Database name | merq_db |
REDIS_HOST | Redis host | localhost |
REDIS_PORT | Redis port | 6379 |
REDIS_PASSWORD | Redis password | redis-password |
JWT_SECRET | JWT signing key | random-256-bit-string |
JWT_EXPIRY_HOURS | Token expiry in hours | 24 |
API Keys
Section titled “API Keys”| Variable | Description |
|---|---|
RESEND_API_KEY | Resend email service |
PLUNK_API_KEY | Plunk email fallback |
MAILERSEND_API_KEY | Mailersend fallback |
FIREBASE_CREDENTIALS_FILE | Firebase service account path |
DO_SPACES_KEY | DigitalOcean Spaces key |
DO_SPACES_SECRET | DigitalOcean Spaces secret |
TYPESENSE_API_KEY | Typesense search API key |
Application Settings
Section titled “Application Settings”| Variable | Description | Default |
|---|---|---|
SERVER_PORT | Server port | 8080 |
APP_ENV | Environment | development |
.env File
Section titled “.env File”Backend
Section titled “Backend”Create .env file in merq-backend/:
# DatabaseDB_HOST=localhostDB_PORT=5432DB_USER=merqDB_PASSWORD=your-secure-passwordDB_NAME=merq_db
# RedisREDIS_HOST=localhostREDIS_PORT=6379REDIS_PASSWORD=redis-password
# AuthJWT_SECRET=your-256-bit-secret-key-change-in-productionJWT_EXPIRY_HOURS=24
# Email (at least one required)RESEND_API_KEY=re_xxxxxRESEND_SENDER_EMAIL=noreply@yourdomain.com
# FirebaseFIREBASE_CREDENTIALS_FILE=./firebase/service-account.json
# DigitalOcean SpacesDO_SPACES_KEY=your-spaces-keyDO_SPACES_SECRET=your-spaces-secretDO_SPACES_BUCKET=your-bucketDO_SPACES_ENDPOINT=https://sgp1.digitaloceanspaces.com
# TypesenseTYPESENSE_HOST=localhostTYPESENSE_PORT=8108TYPESENSE_API_KEY=your-typesense-keyCreate .env.local file in merq-web:
VITE_API_BASE_URL=http://localhost:8080/apiVITE_GOOGLE_API_KEY=your-google-maps-keyVITE_SECURE_LOCAL_STORAGE_HASH_KEY=your-32-char-hash-keyMobile
Section titled “Mobile”Create .env.dev or .env.prod file in merq-mobile:
API_BASE_URL=http://localhost:8080/apiGOOGLE_MAPS_API_KEY=your-google-maps-keySTORAGE_ENC_KEY=your-32-char-encryption-keyProduction Secrets
Section titled “Production Secrets”Docker
Section titled “Docker”# Using environment filedocker run -d \ --name merq-backend \ --env-file .env.production \ merq-backend:latestDocker Compose
Section titled “Docker Compose”version: '3.8'services: backend: image: merq-backend:latest env_file: - .env.productionKubernetes
Section titled “Kubernetes”apiVersion: v1kind: Secretmetadata: name: merq-secretstype: OpaquestringData: DB_PASSWORD: your-password JWT_SECRET: your-secret RESEND_API_KEY: re_xxxxxSecret Rotation
Section titled “Secret Rotation”JWT Secret
Section titled “JWT Secret”- Generate new secret
- Update environment variable
- Deploy application
- Note: All existing tokens become invalid
API Keys
Section titled “API Keys”- Generate new API key from provider
- Update environment variable
- Deploy application
- Revoke old key
Database Password
Section titled “Database Password”- Update password in database:
ALTER USER merq WITH PASSWORD 'new-password';- Update environment variable
- Deploy application
Security Best Practices
Section titled “Security Best Practices”- ✅ Use strong, random secrets (256-bit for JWT)
- ✅ Rotate secrets regularly
- ✅ Use different secrets per environment
- ✅ Store secrets in secure location (Vault, K8s Secrets)
- ✅ Use environment-specific secrets
- ❌ Commit secrets to version control
- ❌ Use default/example secrets in production
- ❌ Share secrets via email/chat
- ❌ Use simple passwords
- ❌ Hardcode secrets in source code
Related Documentation
Section titled “Related Documentation”- Environment Variables - Full variable list
- Installation Guide - Setup guide
- Integrations - Third-party services