feat(logging): hash IP addresses in logs and Sentry integration

- Implemented IP hashing using SHA256 in logs for enhanced privacy.
- Updated Sentry integration to hash IP addresses before sending events.
- Enhanced `AllExceptionsFilter` and `crawler-detection.middleware` to use hashed IPs in logs and error handling.
- Refined request logging in `auth.service` to include hashed email instead of plain text email.
This commit is contained in:
Mathis HERRIOT
2026-02-09 11:05:53 +01:00
parent 378c41ddb2
commit 0706c47a33
5 changed files with 124 additions and 10 deletions

View File

@@ -1,3 +1,4 @@
import { createHash } from "node:crypto";
import { Logger, ValidationPipe } from "@nestjs/common";
import { ConfigService } from "@nestjs/config";
import { NestFactory } from "@nestjs/core";
@@ -24,6 +25,15 @@ async function bootstrap() {
tracesSampleRate: 1.0,
profilesSampleRate: 1.0,
sendDefaultPii: false, // RGPD
beforeSend(event) {
// Hachage de l'IP utilisateur pour Sentry si elle est présente
if (event.user?.ip_address) {
event.user.ip_address = createHash("sha256")
.update(event.user.ip_address)
.digest("hex");
}
return event;
},
});
}