🔐 Security hardening: auth, rate limiting, brute force protection

- Add comprehensive security package with:
  - API Key generation and validation (SHA256 hash)
  - Password policy enforcement (min 12 chars, complexity)
  - Rate limiting with presets (auth, api, ingest, export)
  - Brute force protection (5 attempts, 15min lockout)
  - Security headers middleware
  - IP whitelisting
  - Audit logging structure
  - Secure token generation

- Enhanced auth middleware:
  - JWT + API Key dual authentication
  - Token revocation via Redis
  - Scope-based authorization
  - Role-based access control

- Updated installer with:
  - Interactive setup for client customization
  - Auto-generated secure credentials
  - Docker all-in-one image
  - Agent installer script

- Added documentation:
  - SECURITY.md - Complete security guide
  - INSTALL.md - Installation guide
  - .env.example - Configuration reference
This commit is contained in:
2026-02-05 23:02:06 -03:00
parent dbf9f0497f
commit a94809c812
11 changed files with 2637 additions and 444 deletions

75
.env.example Normal file
View File

@@ -0,0 +1,75 @@
# ═══════════════════════════════════════════════════════════
# 🐍 OPHION - Configuração de Exemplo
# Copie para .env e preencha os valores
# ═══════════════════════════════════════════════════════════
# ─────────────────────────────────────────────────────────────
# Organização
# ─────────────────────────────────────────────────────────────
ORG_NAME="Minha Empresa"
ADMIN_EMAIL=admin@empresa.com
ADMIN_PASSWORD=mude-esta-senha
# ─────────────────────────────────────────────────────────────
# Rede
# ─────────────────────────────────────────────────────────────
DOMAIN=localhost
SERVER_PORT=8080
DASHBOARD_PORT=3000
API_URL=http://ophion-server:8080
# ─────────────────────────────────────────────────────────────
# Segurança (GERE VALORES ÚNICOS!)
# Use: openssl rand -hex 32
# ─────────────────────────────────────────────────────────────
JWT_SECRET=MUDE-ISTO-openssl-rand-hex-32
API_KEY=ophion_MUDE-ISTO-openssl-rand-hex-32
# ─────────────────────────────────────────────────────────────
# PostgreSQL
# ─────────────────────────────────────────────────────────────
POSTGRES_USER=ophion
POSTGRES_PASSWORD=MUDE-ISTO-senha-segura
POSTGRES_DB=ophion
DATABASE_URL=postgres://ophion:MUDE-ISTO-senha-segura@postgres:5432/ophion
# ─────────────────────────────────────────────────────────────
# ClickHouse
# ─────────────────────────────────────────────────────────────
CLICKHOUSE_URL=clickhouse://clickhouse:9000/ophion
# ─────────────────────────────────────────────────────────────
# Redis
# ─────────────────────────────────────────────────────────────
REDIS_URL=redis://redis:6379
# ─────────────────────────────────────────────────────────────
# Alertas - Telegram (opcional)
# ─────────────────────────────────────────────────────────────
TELEGRAM_ENABLED=false
TELEGRAM_BOT_TOKEN=
TELEGRAM_CHAT_ID=
# ─────────────────────────────────────────────────────────────
# Alertas - Slack (opcional)
# ─────────────────────────────────────────────────────────────
SLACK_ENABLED=false
SLACK_WEBHOOK_URL=
# ─────────────────────────────────────────────────────────────
# IA - OpenAI (opcional, para recursos de IA)
# ─────────────────────────────────────────────────────────────
OPENAI_API_KEY=
# ─────────────────────────────────────────────────────────────
# Configurações Gerais
# ─────────────────────────────────────────────────────────────
TZ=America/Sao_Paulo
LOG_LEVEL=info
# ─────────────────────────────────────────────────────────────
# Retenção de Dados
# ─────────────────────────────────────────────────────────────
METRICS_RETENTION_DAYS=90
LOGS_RETENTION_DAYS=30
TRACES_RETENTION_DAYS=14