Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9e30b37

Browse files
committed
Merge pull request #1 from plizy/master
Disable authentication on / to simplify health heck configuration
2 parents 3910c8c + 2a05762 commit 9e30b37

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

‎README.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
This plugin provides an extension of ElasticSearchs HTTP Transport module to enable HTTP Basic authorization.
44

5+
Requesting / does not request authentication to simplify health heck configuration.
6+
57
## Installation
68

79
Download the current version from https://github.com/Asquera/elasticsearch-http-basic/downloads and copy it to `plugins/http-basic`.
@@ -21,8 +23,9 @@ Be aware that the password is stored in plain text.
2123
## Testing
2224

2325
```
24-
$ curl -v --user my_username:my_password localhost:9200 # works
25-
$ curl -v --user my_username:password localhost:9200 # sends 403
26+
$ curl -v localhost:9200 # works
27+
$ curl -v --user my_username:my_password localhost:9200/foo # works
28+
$ curl -v --user my_username:password localhost:9200/foo # sends 401
2629
```
2730

2831
## Problems

‎src/main/java/com/asquera/elasticsearch/plugins/http/HttpBasicServer.java‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.elasticsearch.common.inject.Inject;
99
import org.elasticsearch.common.Base64;
1010

11+
import org.elasticsearch.rest.RestRequest;
1112
import org.elasticsearch.rest.StringRestResponse;
1213

1314
import static org.elasticsearch.rest.RestStatus.*;
@@ -31,12 +32,16 @@ public class HttpBasicServer extends HttpServer {
3132
}
3233

3334
public void internalDispatchRequest(final HttpRequest request, final HttpChannel channel) {
34-
if (authBasic(request)) {
35+
if (shouldLetPass(request) || authBasic(request)) {
3536
super.internalDispatchRequest(request, channel);
3637
} else {
3738
channel.sendResponse(new StringRestResponse(UNAUTHORIZED));
3839
}
3940
}
41+
42+
private boolean shouldLetPass(final HttpRequest request) {
43+
return (request.method() == RestRequest.Method.GET) && request.path().equals("/");
44+
}
4045

4146
private boolean authBasic(final HttpRequest request){
4247
String authHeader = request.header("Authorization");

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /