Skip to content

Commit

Permalink
Replaced needle request to Elastic by callWithInteralUser
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesús Ángel González authored and havidarou committed Apr 24, 2018
1 parent 442c608 commit ac09f03
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions server/lib/elastic-wrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
* Find more information about this on the LICENSE file.
*/
import knownFields from '../integration-files/known-fields';
import needle from 'needle'

export default class ElasticWrapper {
constructor(server){
Expand Down Expand Up @@ -523,17 +522,13 @@ export default class ElasticWrapper {

async usingCredentials() {
try {
const response = await needle('get', `${this.elasticRequest._config.url}/_xpack`, {}, {
username: this.elasticRequest._config.username,
password: this.elasticRequest._config.password
})

const data = await this.elasticRequest.callWithInternalUser('cluster.getSettings', { includeDefaults: true });

return response &&
response.body &&
response.body.features &&
response.body.features.security &&
response.body.features.security.enabled;
return data &&
data.defaults &&
data.defaults.xpack &&
data.defaults.xpack.security &&
data.defaults.xpack.security.enabled;

} catch (error) {
return Promise.reject(error);
Expand Down

0 comments on commit ac09f03

Please sign in to comment.