fix(auth): redact passwords on normalized login paths
- Normalize login paths before applying request-body redaction. - Cover trailing-slash paths and assert the password never reaches logs.
This commit is contained in:
1 parent
de41571b5c
commit
72e127888c
2 files changed
+50
-2
No files matched your search
@@ -9,8 +9,10 @@ import { Observable, tap } from "rxjs";
|
||||
import { TraceLogger } from "../common/trace-logger";
|
||||
|
||||
export function redactAuthRequestBody(path: string, body: unknown): unknown {
|
||||
const normalizedPath = path.toLowerCase().replace(/\/+$/, "");
|
||||
if (
|
||||
!/^(?:\/api\/v1)?\/auth\/login$/.test(path) ||
|
||||
(normalizedPath !== "/auth/login" &&
|
||||
normalizedPath !== "/api/v1/auth/login") ||
|
||||
!body ||
|
||||
typeof body !== "object" ||
|
||||
Array.isArray(body)
|
||||
|
||||
Reference in new issue
Block a user