Seguridad /qr: HTTP Basic Auth con QR_TOKEN dedicado (no secreto en la URL)

Review de seguridad: autenticar por query string filtra el secreto (logs,
historial, Referer) y usaba la misma FUNNEL_API_KEY que autoriza la API.
Ahora /qr usa HTTP Basic (credencial en cabecera), un QR_TOKEN dedicado
distinto de FUNNEL_API_KEY, comparación en tiempo constante (timingSafeEqual
sobre hashes) y Referrer-Policy: no-referrer.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Carlos Narro
2026-06-09 16:51:46 +02:00
parent a43e7a77be
commit a740d08863
2 changed files with 32 additions and 14 deletions

View File

@@ -136,7 +136,7 @@ export class WhatsappService implements OnModuleInit, OnModuleDestroy {
if (qr) {
QRCode.generate(qr, { small: true });
console.log('\n📲 Escanea este QR con WhatsApp (o abre /qr?key=FUNNEL_API_KEY)\n');
console.log('\n📲 Escanea este QR con WhatsApp (o abre la página /qr, protegida con QR_TOKEN)\n');
this.webhookListener.setQr(qr);
}