Skip to content

Commit

Permalink
ensure we're not printing out the authorization token
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki committed Mar 22, 2022
1 parent d935dd7 commit c58f25d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/middleware/requestReponseLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ const stringifyHeaders = (headers?: Headers | HeadersInit) => {
})
} else {
const headersInit = headers as Record<string, string>
for (const key in headersInit) {
if (Object.prototype.isPrototypeOf.call(headersInit, key)) {
const val = headersInit[key]
headerString = `${headerString}${key}:${val};`
console.log('headersInit: ', headersInit)
Object.keys(headersInit).forEach((key) => {
let val = headersInit[key]
if (/authorization/i.test(key)) {
// Authorization: <auth-scheme> <authorization-parameters>
val = `${val.split(' ')[0]} REDACTED`
}
}
headerString = `${headerString}${key}:${val};`
})
}
return headerString
}
Expand Down

0 comments on commit c58f25d

Please sign in to comment.