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:
@@ -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;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user