Skip to content

Commit

Permalink
Merge pull request #4 from Framonti/update-Elasticsearch-to-7.12
Browse files Browse the repository at this point in the history
Update elasticsearch to 7.12
  • Loading branch information
carminexx authored May 24, 2021
2 parents 5871c9f + 18d541d commit a88b0ed
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ There is no way to configure this on a per index basis.
|-----------------------------|------------------------------|
| v0.0.1 | 6.3.2 |
| v0.1.0 | 7.6.0 |

| v0.2.0 | 7.12.0 |

## Installation

Expand Down
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.cleafy.elasticsearch</groupId>
<artifactId>elasticsearch-http-basic-auth-plugin</artifactId>
<version>0.1.0</version>
<version>0.2.0</version>
<packaging>jar</packaging>
<name>Elasticsearch Http Basic plugin</name>
<description>Adds HTTP Basic authentication (BA) to your Elasticsearch cluster</description>
Expand All @@ -15,20 +15,20 @@
<properties>
<tests.jvms>1</tests.jvms>
<es.logger.level>INFO</es.logger.level>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>7.6.0</version>
<version>7.12.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.elasticsearch.test</groupId>
<artifactId>framework</artifactId>
<version>7.6.0</version>
<version>7.12.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -54,7 +54,7 @@
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<appendAssemblyId>true</appendAssemblyId>
<outputDirectory>${project.build.directory}/releases/</outputDirectory>
<descriptors>
<descriptor>${basedir}/src/main/assemblies/plugin.xml</descriptor>
Expand Down
13 changes: 11 additions & 2 deletions src/main/assemblies/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
<?xml version="1.0"?>
<assembly>
<id>plugin</id>
<id>0.2.0</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<outputDirectory>/</outputDirectory>
<directory>src/main/resources</directory>
<includes>
<include>*.properties</include>
</includes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
Expand All @@ -19,7 +28,7 @@
<useProjectArtifact>true</useProjectArtifact>
<useTransitiveFiltering>true</useTransitiveFiltering>
<includes>
<include>com.cleafy.elasticsearch:elasticsearch6-http-basic</include>
<include>com.cleafy.elasticsearch:elasticsearch-http-basic</include>
</includes>
</dependencySet>
</dependencySets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

public class BasicRestFilter {
private final HttpBasicAuthenticator httpBasicAuthenticator;
private boolean isUnauthLogEnabled;
private final boolean isUnauthLogEnabled;

public BasicRestFilter(final Settings settings) {
super();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
public class HttpBasicServerPlugin extends Plugin implements ActionPlugin {

private boolean enabledByDefault = false;
private final boolean enabledByDefault = false;
private final Settings settings;
BasicRestFilter basicFilter;

Expand All @@ -40,9 +40,9 @@ public String description() {
@Override
public UnaryOperator<RestHandler> getRestHandlerWrapper(final ThreadContext threadContext) {
if (this.settings.getAsBoolean(Globals.SETTINGS_ENABLED, enabledByDefault)) {
return (rh) -> basicFilter.wrap(rh);
return rh -> basicFilter.wrap(rh);
}
return (rh) -> rh;
return rh -> rh;
}

@Override
Expand All @@ -58,9 +58,8 @@ public Settings additionalSettings() {

@Override
public List<Setting<?>> getSettings() {
List<Setting<?>> settings = new ArrayList<Setting<?>>();

settings.addAll(super.getSettings());
List<Setting<?>> settings = new ArrayList<>(super.getSettings());

settings.add(Setting.boolSetting(Globals.SETTINGS_ENABLED, enabledByDefault, Setting.Property.NodeScope, Setting.Property.Filtered));
settings.add(Setting.simpleString(Globals.SETTINGS_USERNAME, Setting.Property.NodeScope, Setting.Property.Filtered));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class AuthCredentials {
private final String username;
private byte[] password;
private Object nativeCredentials;
private final Set<String> backendRoles = new HashSet<String>();
private final Set<String> backendRoles = new HashSet<>();
private boolean complete;
private final byte[] internalPasswordHash;
private final Map<String, String> attributes = new HashMap<>();
Expand Down Expand Up @@ -116,11 +116,8 @@ public boolean equals(Object obj) {
if (internalPasswordHash == null || other.internalPasswordHash == null || !MessageDigest.isEqual(internalPasswordHash, other.internalPasswordHash))
return false;
if (username == null) {
if (other.username != null)
return false;
} else if (!username.equals(other.username))
return false;
return true;
return other.username == null;
} else return username.equals(other.username);
}

@Override
Expand All @@ -133,7 +130,7 @@ public String toString() {
* @return Defensive copy of the roles this user is member of.
*/
public Set<String> getBackendRoles() {
return new HashSet<String>(backendRoles);
return new HashSet<>(backendRoles);
}

public boolean isComplete() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import org.elasticsearch.rest.RestRequest;

public class HttpBasicAuthenticator extends Authenticator {
private AuthCredentials credentials;
private final AuthCredentials credentials;

public HttpBasicAuthenticator(Settings settings, AuthCredentials credentials) {
super(settings);
Expand All @@ -13,10 +13,7 @@ public HttpBasicAuthenticator(Settings settings, AuthCredentials credentials) {

@Override
public boolean authenticate(RestRequest request) {
if (this.extractCredentials(request).equals(credentials)) {
return true;
}
return false;
return this.extractCredentials(request).equals(credentials);
}

private AuthCredentials extractCredentials(final RestRequest request) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin-descriptor.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ name=elasticsearch-http-basic-auth-plugin
description=Plugin to enable HTTP basic authentication and/or Ip based authentication
version=1.0.0
java.version=1.8
elasticsearch.version=7.6.0
elasticsearch.version=7.12.0

0 comments on commit a88b0ed

Please sign in to comment.