From f154f5409e2919801d3ec469b8dbc21da0037312 Mon Sep 17 00:00:00 2001 From: Anton Drukh Date: Fri, 4 Aug 2017 15:04:32 +0300 Subject: [PATCH] fix: allow filtering by request headers --- lib/filters/index.js | 8 +++----- lib/relay.js | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/filters/index.js b/lib/filters/index.js index e38c54b0e..cc9c242da 100644 --- a/lib/filters/index.js +++ b/lib/filters/index.js @@ -89,14 +89,12 @@ module.exports = ruleSource => { logger.debug({ path, origin, url }, 'match'); - // GITLAB support + // GITLAB support hack // request comes in with dummy token, replace with config if (config.GITLAB_TOKEN && req.headers) { - if (req.headers['private-token'] === 'dummy_token') { - req.headers['private-token'] = config.GITLAB_TOKEN; - } + req.headers['private-token'] = config.GITLAB_TOKEN; }; - + querystring = (querystring) ? `?${querystring}` : ''; return origin + url + querystring; }; diff --git a/lib/relay.js b/lib/relay.js index 0dab653ea..f90064529 100644 --- a/lib/relay.js +++ b/lib/relay.js @@ -57,8 +57,8 @@ function responseHandler(filterRules, config) { return (brokerToken) => ({ url, headers, method, body = null } = {}, emit) => { // run the request through the filter - logger.info({ method, url }, 'request captured'); - filters({ url, method, body }, (error, result) => { + logger.info({ method, url, headers }, 'request captured'); + filters({ url, method, body, headers }, (error, result) => { if (error) { logger.info({ method, url }, 'blocked'); return emit({