Skip to content

Commit

Permalink
Merge pull request #69 from snyk/fix/filter-headers
Browse files Browse the repository at this point in the history
fix: allow filtering by request headers
  • Loading branch information
adrukh authored Aug 4, 2017
2 parents 5463c12 + f154f54 commit 0d641aa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions lib/filters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
4 changes: 2 additions & 2 deletions lib/relay.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 0d641aa

Please sign in to comment.