feat(api): login web con sesiones, guard global y freno a fuerza bruta
- POST /api/auth/login (U_WEB_USER/U_WEB_PASS de EmployeesInfo), logout y me. - Token opaco (32 bytes) en Authorization: Bearer; una sesión por usuario, timeout deslizante configurable (SESSION_TIMEOUT_MINUTES, 30 por defecto). - AuthGuard global con @Public(); /health/sap ahora exige sesión. - Usuario inexistente y contraseña errónea devuelven el mismo mensaje; comparación en tiempo constante; filtro OData escapado; se rechazan U_WEB_USER duplicados. - LoginAttemptsService: 429 tras 5 fallos por usuario o 20 por IP (15 min). - Tests unitarios y e2e con SAP simulado. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bb4acb5510
commit
079cedbaed
18 files changed
+673
-6
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { Public } from '../auth/public.decorator.js';
|
||||
import { AppConfigService } from '../config/app-config.service.js';
|
||||
import { SapSessionService } from '../sap/sap-session.service.js';
|
||||
|
||||
@@ -9,12 +10,13 @@ export class HealthController {
|
||||
private readonly config: AppConfigService,
|
||||
) {}
|
||||
|
||||
@Public()
|
||||
@Get()
|
||||
check() {
|
||||
return { status: 'ok', uptime: Math.round(process.uptime()) };
|
||||
}
|
||||
|
||||
// TODO(auth): proteger con el guard de sesión cuando exista el login.
|
||||
/** Requiere sesión web (guard global). */
|
||||
@Get('sap')
|
||||
async sap() {
|
||||
await this.sessions.getSession();
|
||||
|
||||
Reference in new issue
Block a user