Browse files

Update readme and fix style for basic auth support, changed auth_logi…

…n to auth_user to match http_basic plugin and xhr spec
  • Loading branch information...
1 parent 6761cfe commit b90c4cdf6d7f3ee6867eebf69dde208a3af3e841 @mobz committed Mar 6, 2013
Showing with 24 additions and 17 deletions.
  1. +9 −0 README.textile
  2. +6 −6 index.html
  3. +9 −11 lib/es/widgets.js
View
9 README.textile
@@ -21,6 +21,15 @@ This will automatically download the latest version of elasticsearch-head from g
* is available at "http://localhost:9200/_plugin/head/":http://localhost:9200/_plugin/head/ (or whatever the address of your cluster is)
* Will not work with elasticsearch prior to version 0.17
+h5. URL Parameters
+
+Parameters may be appended to the url set some initial state eg. @head/index.html?base_uri=http://node-01.example.com:9200@
+
+* @base_uri@ force elasticsearch-head to connect to a particular node.
+* @auth_user@ adds basic auth credentials to http requests ( requires "elasticsearch-http-basic":https://github.com/karussell/elasticsearch-http-basic plugin)
+* @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* )
+
+
h4. Running as a standalone webapp
* @git clone git://github.com/mobz/elasticsearch-head.git@
View
12 index.html
@@ -38,12 +38,12 @@
var args = location.search.substring(1).split("&").reduce(function(r, p) {
r[decodeURIComponent(p.split("=")[0])] = decodeURIComponent(p.split("=")[1]); return r;
}, {});
- new es.ElasticSearchHead("body",
- { id: "es",
- base_uri: args["base_uri"] || base_uri,
- login : args["auth_login"] || "",
- password : args["auth_password"]
- });
+ new es.ElasticSearchHead("body", {
+ id: "es",
+ base_uri: args["base_uri"] || base_uri,
+ auth_user : args["auth_user"] || "",
+ auth_password : args["auth_password"]
+ });
});
</script>
<link rel="icon" href="lib/es/images/favicon.png" type="image/png">
View
20 lib/es/widgets.js
@@ -1348,20 +1348,18 @@
init: function(parent) {
this._super();
this.base_uri = this.config.base_uri;
- if (this.base_uri.charAt(this.base_uri.length-1) !== "/") {
+ if( this.base_uri.charAt( this.base_uri.length - 1 ) !== "/" ) {
// XHR request fails if the URL is not ending with a "/"
this.base_uri += "/";
}
-
- if(this.config.login && this.config.login.length > 0) {
- var userAndPw = this.config.login + ":" + this.config.password;
- var credentials = window.btoa(userAndPw);
- $.ajaxSetup({
- headers: {
- 'Authorization': "Basic " + credentials
- }
- });
- }
+ if( this.config.auth_user ) {
+ var credentials = window.btoa( this.config.auth_user + ":" + this.config.auth_password );
+ $.ajaxSetup({
+ headers: {
+ "Authorization": "Basic " + credentials
+ }
+ });
+ }
this.cluster = new es.Cluster({ base_uri: this.base_uri });
this._initElements(parent);
this.instances = {};

0 comments on commit b90c4cd

Please sign in to comment.