Skip to content

Commit

Permalink
Merge pull request #25 from aerospike/develop
Browse files Browse the repository at this point in the history
v1.6.1
  • Loading branch information
reugn authored Jul 27, 2020
2 parents 7488e57 + 0fd2486 commit 5c353fd
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 17 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ See [Installation and Configuration](./docs/installation-and-config.md) for inst
Use [Basic access authentication](https://en.wikipedia.org/wiki/Basic_access_authentication) to enable multi-user tenancy in the Aerospike REST client.
Please note that only Aerospike Enterprise Edition supports the [security features](https://aerospike.com/docs/guide/security/index.html).

For example, having the default `admin:admin` credentials, send the `Authorization: Basic YWRtaW46YWRtaW4=` header with the request to make an authenticated query.

## Data Formats and API

### Formats
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
springBootVersion = '2.2.6.RELEASE'
springBootVersion = '2.3.1.RELEASE'
springfoxVersion = '2.9.2'
httpclientVersion = '4.5.12'
aerospikeClientVersion = findProperty('aerospikeClientVersion') ?:'4.4.15'
Expand Down Expand Up @@ -60,6 +60,7 @@ dependencies {
compile("io.springfox:springfox-swagger2:${springfoxVersion}")
compile("io.springfox:springfox-swagger-ui:${springfoxVersion}")
compile("javax.inject:javax.inject:1")
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation "org.apache.httpcomponents:httpclient:${httpclientVersion}"
testCompile('org.springframework.boot:spring-boot-starter-test')
}
2 changes: 1 addition & 1 deletion demos/sample-rest-stockapp/swagger/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"swagger": "2.0",
"info": {
"description": "REST Interface for Aerospike Database.",
"version": "1.5.0",
"version": "1.6.1",
"title": "Aerospike REST Client",
"contact": {
"name": "Aerospike, Inc.",
Expand Down
16 changes: 10 additions & 6 deletions docs/installation-and-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
./gradlew bootRun
```

### Run from Jar file
### Run using a Jar file
```
java -jar build/libs/aerospike-client-rest-<VERSION>.jar
```
The fully executable jar contains an extra script at the front of the file, which allows you to just symlink your Spring Boot jar to init.d or use a systemd script.
More information at the following links:
* [Installation as an init.d service](https://docs.spring.io/spring-boot/docs/2.2.6.RELEASE/reference/htmlsingle/#deployment-service)
* [Installation as a systemd service](https://docs.spring.io/spring-boot/docs/2.2.6.RELEASE/reference/htmlsingle/#deployment-systemd-service)
* [Installation as an init.d service](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#deployment-service)
* [Installation as a systemd service](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#deployment-systemd-service)

### Run using Docker
* Build the docker image
Expand Down Expand Up @@ -58,6 +58,7 @@ test out various commands in your browser.
The Swagger specification, in `JSON` format, can be found at <http://localhost:8080/v2/api-docs> .

## Configuration
Read more about Spring Boot [Externalized Configuration](https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-external-config).

* `server.port` Change the port the REST Client is listening on (default: 8080)
* `aerospike.restclient.hostname` The IP address or Hostname of a seed node in the cluster (default: `localhost`)
Expand Down Expand Up @@ -88,13 +89,16 @@ The REST Client also allows authentication to an Aerospike Enterprise edition se
* `aerospike.restclient.clientpolicy.user` This is the name of a user registered with the Aerospike database. This variable is only needed when the Aerospike cluster is running with security enabled.
* `aerospike.restclient.clientpolicy.password` This is the password for the previously specified user. This variable is only needed when the Aerospike cluster is running with security enabled.

Multi-user authentication configuration variables:
To utilize the multi-tenancy capability within the REST Client, send Aerospike login credentials using the [Basic access authentication](https://en.wikipedia.org/wiki/Basic_access_authentication).
Set custom multi-user authentication configuration variables if needed:
* `aerospike.restclient.requireAuthentication` Set this boolean flag to true to require the Basic Authentication on each request.
* `aerospike.restclient.pool.size` Represents the max size of the clients LRU cache (default value: 16)
* `aerospike.restclient.pool.size` Represents the max size of the authenticated clients LRU cache (default value: 16).
Please note that an oversized client cache will consume a lot of resources and affect the performance.

### TLS Configuration

Beginning with version `1.1.0` the Aerospike REST Client supports TLS communication between the client and the Aerospike Server. (This feature requires an Enterprise Edition Aerospike Server). If utilizing TLS, the `aerospike.restclient.hostlist` variable should be set to include appropriate TLS Names for each of the Aerospike Nodes. For example: `localhost:cluster-tls-name:4333` The following environment variables allow configuration of this connection:
Beginning with version `1.1.0` the Aerospike REST Client supports TLS communication between the client and the Aerospike Server. (This feature requires an Enterprise Edition Aerospike Server).
If utilizing TLS, the `aerospike.restclient.hostlist` variable should be set to include appropriate TLS Names for each of the Aerospike Nodes. For example: `localhost:cluster-tls-name:4333` The following environment variables allow configuration of this connection:

* `aerospike.restclient.ssl.enabled` boolean, set to `true` to enable a TLS connection with the Aerospike Server. If no other SSL environment variables are provided, the REST client will attempt to establish a secure connection utilizing the default Java SSL trust and keystore settings. Default: `false`
* `aerospike.restclient.ssl.keystorepath` The path to a Java KeyStore to be used to interact with the Aerospike Server. If omitted the default Java KeyStore location and password will be used.
Expand Down
2 changes: 1 addition & 1 deletion docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"swagger": "2.0",
"info": {
"description": "REST Interface for Aerospike Database.",
"version": "1.5.0",
"version": "1.6.1",
"title": "Aerospike REST Client",
"contact": {
"name": "Aerospike, Inc.",
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
appVersion=1.6.0
appVersion=1.6.1
jarBaseName=as-rest-client
10 changes: 3 additions & 7 deletions src/test/java/com/aerospike/restclient/ASTestUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -592,13 +592,9 @@ public static boolean compareRCOperations(RestClientOperation expected, RestClie
}

if (expectedOpVals != null) {
if (!compareMapStringObj(expectedOpVals, otherOpVals)) {
return false;
}
} else if (otherOpVals != null) {
return false;
return compareMapStringObj(expectedOpVals, otherOpVals);
}

return true;
return otherOpVals == null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public void testValidUserAuthentication() throws Exception {

@Test
public void testInvalidUserAuthentication() throws Exception {
if (!ClusterUtils.isSecurityEnabled(client)) return;

mockMVC.perform(get(testEndpoint)
.header("Authorization", invalidAuthHeader))
.andExpect(status().isInternalServerError());
Expand Down
48 changes: 48 additions & 0 deletions src/test/java/com/aerospike/restclient/ClusterUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2020 Aerospike, Inc.
*
* Portions may be licensed to Aerospike, Inc. under one or more contributor
* license agreements WHICH ARE COMPATIBLE WITH THE APACHE LICENSE, VERSION 2.0.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package com.aerospike.restclient;

import com.aerospike.client.AerospikeClient;
import com.aerospike.client.AerospikeException;
import com.aerospike.client.Info;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class ClusterUtils {

private static final Logger logger = LoggerFactory.getLogger(ClusterUtils.class);

private ClusterUtils() {
}

public static boolean isEnterpriseEdition(AerospikeClient client) {
String infoEdition = Info.request(null, client.getCluster().getRandomNode(), "edition");
return infoEdition.contains("Enterprise");
}

public static boolean isSecurityEnabled(AerospikeClient client) {
if (isEnterpriseEdition(client)) {
try {
client.queryRoles(null);
return true;
} catch (AerospikeException e) {
logger.info("Aerospike Server Enterprise Edition security disabled");
}
}
return false;
}
}

0 comments on commit 5c353fd

Please sign in to comment.