77 lines
4.0 KiB
Plaintext
77 lines
4.0 KiB
Plaintext
═══════════════════════════════════════════════════════════
|
|
🔐 COMO GERAR CHAVES JWT E SESSION SEGURAS
|
|
═══════════════════════════════════════════════════════════
|
|
|
|
As chaves JWT_SECRET e SESSION_SECRET DEVEM ser aleatórias
|
|
e diferentes uma da outra para segurança máxima.
|
|
|
|
═══════════════════════════════════════════════════════════
|
|
🛠️ MÉTODO 1: Via Terminal Linux (RECOMENDADO)
|
|
═══════════════════════════════════════════════════════════
|
|
|
|
Execute estes comandos no terminal do seu VPS:
|
|
|
|
# Gerar JWT_SECRET
|
|
openssl rand -hex 32
|
|
|
|
# Gerar SESSION_SECRET
|
|
openssl rand -hex 32
|
|
|
|
Você verá algo assim:
|
|
a8f5f167f44f4964e6c998dee827110c7c8d0c88e04d89e1c3b9b8e1f8e9e8a1
|
|
b4c7f8a9e3d2f1a8b7c6d5e4f3a2b1c8d7e6f5a4b3c2d1e8f7a6b5c4d3e2f1
|
|
|
|
Copie cada uma e cole no .env:
|
|
JWT_SECRET=a8f5f167f44f4964e6c998dee827110c7c8d0c88e04d89e1c3b9b8e1f8e9e8a1
|
|
SESSION_SECRET=b4c7f8a9e3d2f1a8b7c6d5e4f3a2b1c8d7e6f5a4b3c2d1e8f7a6b5c4d3e2f1
|
|
|
|
═══════════════════════════════════════════════════════════
|
|
🛠️ MÉTODO 2: Via Node.js (RÁPIDO)
|
|
═══════════════════════════════════════════════════════════
|
|
|
|
No terminal, execute:
|
|
|
|
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
|
|
|
|
Repita 2 vezes e copie cada resultado.
|
|
|
|
═══════════════════════════════════════════════════════════
|
|
🛠️ MÉTODO 3: Manualmente (SE NÃO TIVER OPENSSL)
|
|
═══════════════════════════════════════════════════════════
|
|
|
|
Use QUALQUER texto longo e aleatório que você inventar:
|
|
|
|
BOM EXEMPLO:
|
|
JWT_SECRET=MinhaChaveSuperSecretaParaJWT123456789AgoraEstamuitoSegura
|
|
SESSION_SECRET=OutraChaveCompletamenteDiferenteParaSession987654321SeguraTambem
|
|
|
|
RUIM EXEMPLO (não usar):
|
|
JWT_SECRET=senha123
|
|
SESSION_SECRET=123456
|
|
|
|
═══════════════════════════════════════════════════════════
|
|
✅ CHECKLIST
|
|
═══════════════════════════════════════════════════════════
|
|
|
|
□ JWT_SECRET gerada (longa e aleatória)
|
|
□ SESSION_SECRET gerada (diferente da JWT)
|
|
□ Ambas são diferentes entre si
|
|
□ Usei os métodos seguros acima
|
|
|
|
═══════════════════════════════════════════════════════════
|
|
💡 DICAS
|
|
═══════════════════════════════════════════════════════════
|
|
|
|
1. Quanto mais longa, mais segura
|
|
2. Use símbolos, números, letras
|
|
3. Guarde as chaves em local seguro
|
|
4. NUNCA compartilhe estas chaves
|
|
5. Ambas DEVEM ser diferentes
|
|
|
|
═══════════════════════════════════════════════════════════
|
|
|
|
Versão: 2.0.1
|
|
Data: 2025-01-26
|
|
|
|
═══════════════════════════════════════════════════════════
|