Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrome extension doesn't work against local unauthenticated instance #18

Closed
tjrobinson opened this issue Oct 11, 2016 · 13 comments
Closed

Comments

@tjrobinson
Copy link

I've installed the latest Chrome extension from the Chrome store.

When I connect to http://127.0.0.1:9200 or http://localhost:9200 it fails with:

Authentication Error

It looks like your app name, username, password combination doesn't match.
Check your url and appname and then connect it again.

I've added this to my elasticsearch.yml file and restarted before doing the above:

http.cors.allow-origin: "http://127.0.0.1:9200"
http.cors.enabled: true
http.cors.allow-headers : X-Requested-With,X-Auth-Token,Content-Type, Content-Length, Authorization
http.cors.allow-credentials: true
@tjrobinson
Copy link
Author

Looking in the Chrome console I see that:

username: "127.0.0.1", password: "9200"

@farhan687
Copy link
Contributor

Hey @tjrobinson It looks like CORS error, your allow origin should be like this

http.cors.allow-origin: "*"

Steps:

  1. Stop elasticsearch
  2. update config
    Es config:
http.cors.allow-origin: "*"
http.cors.enabled: true
http.cors.allow-headers : "X-Requested-With, X-Auth-Token, Content-Type, Content-Length, Authorization"
http.cors.allow-methods: "OPTIONS, HEAD, GET, POST, PUT, DELETE"
http.cors.allow-credentials: true
  1. start elasticsearch

  2. Open console and try to make a request.

var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://localhost:9200/_search', true);
xhr.withCredentials = true;
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.setRequestHeader('Authorization', 'Basic ' + btoa('test:test'));
xhr.send('{"query":{"match_all":{}}}');

If it's response status is 200 then try with mirage, mirage should work after that. If you are facing any error in request post the error log over here or checkout CORS issue for elasticsearch

@tjrobinson
Copy link
Author

I've done that and Mirage is still giving the same error.

Using the Chrome console I get this:

image

I think the problem is that we have no authentiction set up on our ES instances, but Mirage and your script above send credentials?

@farhan687
Copy link
Contributor

I just confirmed, mirage chrome extension is working fine with local connection.
and yes it was my mistake in above steps.

Es config should be:

http.cors.enabled: true
http.cors.allow-origin: "/.*/"
http.cors.allow-credentials: true
http.cors.allow-headers: "Authorization, X-Requested-With, Content-Type, Content-Length"

and still if you see the issue, please provide detail of es version.

@tjrobinson
Copy link
Author

Thanks. It's looking better but I'm still getting an error. I'm on Elasticsearch 2.3.4 on Windows 10 (can't upgrade currently as I need to match what we're running in production):

image

@farhan687
Copy link
Contributor

farhan687 commented Oct 14, 2016

This is little bit confusing, I cannot see any error message in console log. Still you are getting error on UI this is strange. Can you just try disconnecting and connecting?

and can you also try on gh-pages? appbaseio.github.io/mirage

@tjrobinson
Copy link
Author

I've sorted it. I was connecting to the index via the alias not the actual index name. It works if I use the index name. Not sure if that's a bug or just me doing it wrong?

GET /_cat/aliases?v

alias                  index                    filter routing.index routing.search 
empactis_local_bluesky empactis_local_blueskyv5 -      -             -              

@tjrobinson
Copy link
Author

I see the same issue (and solution) with the gh-pages version and the plugin too.

@farhan687
Copy link
Contributor

@tjrobinson yes, so mirage is not creating anything for you. it is just an query explorer.

you can create indexes and view data using dejavu.

@tjrobinson
Copy link
Author

The index and the alias exist already. I was expecting to be able to use either the alias or the index name when querying.

@farhan687
Copy link
Contributor

Okay, I will check it out if we can support alias also for connection.

@tjrobinson
Copy link
Author

Great, thanks. Nice tools by the way, good work.

@bbugh
Copy link

bbugh commented Apr 20, 2018

Anyone else stuck on this, I had to add the options to the elastic config, restart, and then use 127.0.0.1 instead of localhost to be able to connect to my local instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants