Make callWithRequest use whitelisted headers

This commit is contained in:
Shaunak Kashyap 2016-04-14 18:12:16 -07:00
parent f9f4b79626
commit 7f75efb43a
No known key found for this signature in database
GPG key ID: 0512E188DDE4FF2A
2 changed files with 6 additions and 6 deletions

View file

@ -3,12 +3,12 @@ import Promise from 'bluebird';
import Boom from 'boom';
import getBasicAuthRealm from './get_basic_auth_realm';
import toPath from 'lodash/internal/toPath';
import filterHeaders from './filter_headers';
module.exports = (client) => {
module.exports = (server, client) => {
return (req, endpoint, params = {}) => {
if (req.headers.authorization) {
_.set(params, 'headers.authorization', req.headers.authorization);
}
const filteredHeaders = filterHeaders(req.headers, server.config().get('elasticsearch.requestHeaders'));
_.set(params, 'headers', filteredHeaders);
const path = toPath(endpoint);
const api = _.get(client, path);
let apiContext = _.get(client, path.slice(0, -1));

View file

@ -78,8 +78,8 @@ module.exports = function (server) {
server.expose('ElasticsearchClientLogging', ElasticsearchClientLogging);
server.expose('client', client);
server.expose('createClient', createClient);
server.expose('callWithRequestFactory', callWithRequest);
server.expose('callWithRequest', callWithRequest(noAuthClient));
server.expose('callWithRequestFactory', _.partial(callWithRequest, server));
server.expose('callWithRequest', callWithRequest(server, noAuthClient));
server.expose('errors', elasticsearch.errors);
return client;