0

I am implementing the suggestions / autocomplete for my search tool built using elasticsearch.

In order to implement the autocomplete, I need to make an ajax call to my elasticsearch instance. But that is giving away my credentials to connect to the elasticsearch.

Following is my code:

$.ajax({
  "async": true,
  "crossDomain": true,
  "url": "http://{userName}:{Password}localhost:9200/{index}/_search",
  "method": "POST",
  "headers": {
    "cache-control": "no-cache",
    "content-type": "application/x-www-form-urlencoded",
    "Access-Control-Allow-Origin": "*"
  },
  "data": {
    query
  }
});
urbz
  • 2,663
  • 1
  • 19
  • 29
Amriteya
  • 1,118
  • 15
  • 37
  • Read [this](https://www.elastic.co/blog/found-elasticsearch-security), [this](https://brudtkuhl.com/securing-elasticsearch/) and [this](https://www.nginx.com/blog/nginx-elasticsearch-better-together/). – urbz Apr 15 '16 at 09:14
  • and then this perhaps? http://stackoverflow.com/questions/14579478/how-to-pass-credentials-for-a-webservice-using-jquery-ajax-call – mplungjan Apr 15 '16 at 09:14

0 Answers0