Skip to content

Commit b90c4cd

Browse files
committed
Update readme and fix style for basic auth support, changed auth_login to auth_user to match http_basic plugin and xhr spec
1 parent 6761cfe commit b90c4cd

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

README.textile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ This will automatically download the latest version of elasticsearch-head from g
2121
* is available at "http://localhost:9200/_plugin/head/":http://localhost:9200/_plugin/head/ (or whatever the address of your cluster is)
2222
* Will not work with elasticsearch prior to version 0.17
2323

24+
h5. URL Parameters
25+
26+
Parameters may be appended to the url set some initial state eg. @head/index.html?base_uri=http://node-01.example.com:9200@
27+
28+
* @base_uri@ force elasticsearch-head to connect to a particular node.
29+
* @auth_user@ adds basic auth credentials to http requests ( requires "elasticsearch-http-basic":https://github.com/karussell/elasticsearch-http-basic plugin)
30+
* @auth_password@ basic auth password as above (note: without "additional security layers":http://security.stackexchange.com/questions/988/is-basic-auth-secure-if-done-over-https, passwords are sent over the network *in the clear* )
31+
32+
2433
h4. Running as a standalone webapp
2534

2635
* @git clone git://github.com/mobz/elasticsearch-head.git@

index.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@
3838
var args = location.search.substring(1).split("&").reduce(function(r, p) {
3939
r[decodeURIComponent(p.split("=")[0])] = decodeURIComponent(p.split("=")[1]); return r;
4040
}, {});
41-
new es.ElasticSearchHead("body",
42-
{ id: "es",
43-
base_uri: args["base_uri"] || base_uri,
44-
login : args["auth_login"] || "",
45-
password : args["auth_password"]
46-
});
41+
new es.ElasticSearchHead("body", {
42+
id: "es",
43+
base_uri: args["base_uri"] || base_uri,
44+
auth_user : args["auth_user"] || "",
45+
auth_password : args["auth_password"]
46+
});
4747
});
4848
</script>
4949
<link rel="icon" href="lib/es/images/favicon.png" type="image/png">

lib/es/widgets.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,20 +1348,18 @@
13481348
init: function(parent) {
13491349
this._super();
13501350
this.base_uri = this.config.base_uri;
1351-
if (this.base_uri.charAt(this.base_uri.length-1) !== "/") {
1351+
if( this.base_uri.charAt( this.base_uri.length - 1 ) !== "/" ) {
13521352
// XHR request fails if the URL is not ending with a "/"
13531353
this.base_uri += "/";
13541354
}
1355-
1356-
if(this.config.login && this.config.login.length > 0) {
1357-
var userAndPw = this.config.login + ":" + this.config.password;
1358-
var credentials = window.btoa(userAndPw);
1359-
$.ajaxSetup({
1360-
headers: {
1361-
'Authorization': "Basic " + credentials
1362-
}
1363-
});
1364-
}
1355+
if( this.config.auth_user ) {
1356+
var credentials = window.btoa( this.config.auth_user + ":" + this.config.auth_password );
1357+
$.ajaxSetup({
1358+
headers: {
1359+
"Authorization": "Basic " + credentials
1360+
}
1361+
});
1362+
}
13651363
this.cluster = new es.Cluster({ base_uri: this.base_uri });
13661364
this._initElements(parent);
13671365
this.instances = {};

0 commit comments

Comments
 (0)