mirror of
https://github.com/skooner-k8s/skooner.git
synced 2026-02-14 17:49:55 +00:00
scrub headers when logging
This commit is contained in:
@@ -98,9 +98,23 @@ function onError(err, req, res) {
|
||||
console.log('Error in proxied request', err, req.method, req.url);
|
||||
}
|
||||
|
||||
const SENSITIVE_HEADER_KEYS = ['authorization'];
|
||||
|
||||
function scrubHeaders(headers) {
|
||||
const res = Object.assign({}, headers);
|
||||
SENSITIVE_HEADER_KEYS.forEach(function(key) {
|
||||
if (res.hasOwnProperty(key)) {
|
||||
delete res[key];
|
||||
}
|
||||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
function onProxyRes(proxyRes, req, res) {
|
||||
console.log('VERBOSE REQUEST', req.method, req.protocol, req.hostname, req.url, req.headers);
|
||||
console.log('VERBOSE RESPONSE', proxyRes.statusCode, proxyRes.headers);
|
||||
const reqHeaders = scrubHeaders(req.headers);
|
||||
console.log('VERBOSE REQUEST', req.method, req.protocol, req.hostname, req.url, reqHeaders);
|
||||
const proxyResHeaders = scrubHeaders(proxyRes.headers);
|
||||
console.log('VERBOSE RESPONSE', proxyRes.statusCode, proxyResHeaders);
|
||||
}
|
||||
|
||||
function handleErrors(err, req, res, next) {
|
||||
|
||||
Reference in New Issue
Block a user