Skip to content

Commit

Permalink
Add support for elasticsearch 7.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Sessa committed Mar 25, 2020
1 parent 1dca0c7 commit cdc6260
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 31 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Build Status](https://travis-ci.org/Cleafy/elasticsearch6-http-basic.svg?branch=master)](https://github.com/Cleafy/elasticsearch6-http-basic)


# HTTP Basic auth for ElasticSearch 6.x
# HTTP Basic auth for ElasticSearch

This plugin provides an extension of ElasticSearchs HTTP Transport module to enable **HTTP basic authentication** and/or
**Ip based authentication**.
Expand All @@ -16,7 +16,8 @@ There is no way to configure this on a per index basis.

| Http Basic Plugin | elasticsearch |
|-----------------------------|------------------------------|
| v1.0.0 | 6.3.2 |
| v0.0.1 | 6.3.2 |
| v0.1.0 | 7.6.0 |


## Installation
Expand Down
16 changes: 8 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cleafy.elasticsearch6</groupId>
<artifactId>elasticsearch6-http-basic</artifactId>
<version>0.0.1</version>
<groupId>com.cleafy.elasticsearch</groupId>
<artifactId>elasticsearch-http-basic</artifactId>
<version>0.1.0</version>
<packaging>jar</packaging>
<name>Elasticsearch 6.x Http Basic plugin</name>
<name>Elasticsearch Http Basic plugin</name>
<description>Adds HTTP Basic authentication (BA) to your Elasticsearch cluster</description>
<url>https://github.com/Cleafy/elasticsearch-http-basic</url>
<url>https://github.com/Cleafy/elasticsearch6-http-basic</url>
<inceptionYear>2018</inceptionYear>

<properties>
Expand All @@ -21,14 +21,14 @@
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>6.3.2</version>
<version>7.6.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.elasticsearch.test</groupId>
<artifactId>framework</artifactId>
<version>6.3.2</version>
<version>7.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -40,7 +40,7 @@
</dependencies>

<build>
<finalName>elasticsearch6-http-basic-plugin</finalName>
<finalName>elasticsearch-http-basic-plugin</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.cleafy.elasticsearch6.plugins.http;
package com.cleafy.elasticsearch.plugins.http;

import com.cleafy.elasticsearch6.plugins.http.auth.AuthCredentials;
import com.cleafy.elasticsearch6.plugins.http.auth.HttpBasicAuthenticator;
import com.cleafy.elasticsearch6.plugins.http.utils.Globals;
import com.cleafy.elasticsearch6.plugins.http.utils.LoggerUtils;
import com.cleafy.elasticsearch.plugins.http.auth.AuthCredentials;
import com.cleafy.elasticsearch.plugins.http.auth.HttpBasicAuthenticator;
import com.cleafy.elasticsearch.plugins.http.utils.Globals;
import com.cleafy.elasticsearch.plugins.http.utils.LoggerUtils;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.settings.Settings;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.cleafy.elasticsearch6.plugins.http;
package com.cleafy.elasticsearch.plugins.http;

import com.cleafy.elasticsearch6.plugins.http.utils.Globals;
import com.cleafy.elasticsearch.plugins.http.utils.Globals;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Setting;
import org.elasticsearch.common.settings.Settings;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cleafy.elasticsearch6.plugins.http.auth;
package com.cleafy.elasticsearch.plugins.http.auth;

import org.elasticsearch.ElasticsearchSecurityException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cleafy.elasticsearch6.plugins.http.auth;
package com.cleafy.elasticsearch.plugins.http.auth;

import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.RestRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cleafy.elasticsearch6.plugins.http.auth;
package com.cleafy.elasticsearch.plugins.http.auth;

import java.nio.charset.StandardCharsets;
import java.util.Base64;
Expand All @@ -14,13 +14,6 @@ public static AuthCredentials extractCredentials(String authorizationHeader) {
final String decodedBasicHeader = new String(Base64.getDecoder().decode(authorizationHeader.split(" ")[1]),
StandardCharsets.UTF_8);

//username:password
//special case
//username must not contain a :, but password is allowed to do so
// username:pass:word
//blank password
// username:

final int firstColonIndex = decodedBasicHeader.indexOf(':');

String username = null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cleafy.elasticsearch6.plugins.http.auth;
package com.cleafy.elasticsearch.plugins.http.auth;

import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.RestRequest;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cleafy.elasticsearch6.plugins.http.utils;
package com.cleafy.elasticsearch.plugins.http.utils;

public class Globals {
public static final String SETTINGS_ENABLED = "http.basic.enabled";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.cleafy.elasticsearch6.plugins.http.utils;
package com.cleafy.elasticsearch.plugins.http.utils;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand Down Expand Up @@ -36,6 +36,6 @@ public static void logUnAuthorizedRequest(final RestRequest request, Class<?> kl
}

private static InetAddress getAddress(RestRequest request) {
return ((InetSocketAddress) request.getRemoteAddress()).getAddress();
return ((InetSocketAddress) request.getHttpChannel().getRemoteAddress()).getAddress();
}
}

0 comments on commit cdc6260

Please sign in to comment.