Skip to content

Commit 1693f8c

Browse files
Merge branch 'master' into login-error-response-bodies
2 parents 68b2faa + 2e7ed8d commit 1693f8c

File tree

10 files changed

+234
-101
lines changed

10 files changed

+234
-101
lines changed

README.md

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,6 @@ NOTE: Although the binary artifact produced by the project is backwards-compati
1313

1414
This Change
1515
-----------
16-
This change generalizes the vault Java driver to allow prefix paths to
17-
contain multiple path elements. That is, instead of restricting v2 paths
18-
to be **v1**/*something*/**data**/*anything*/*else* (e.g., for a read or write),
19-
paths can be **v1**/*my*/*long*/*prefix*/*path*/**data**/*anything*/*else*.
20-
The length of the prefix path in path elements, or the prefix path itself
21-
(from which the length in path elements can be derived) is passed in the
22-
VaultConfig build sequence. This allows Vault administrators greater
23-
flexibility in configuring the system.
24-
25-
The default is a prefix path length of one, which makes the library's
26-
behavior backwards-compatible with v5.0.0.
2716

2817
Table of Contents
2918
-----------------
@@ -48,7 +37,7 @@ The driver is available from Maven Central, for all modern Java build systems.
4837
Gradle:
4938
```
5039
dependencies {
51-
implementation 'com.bettercloud:vault-java-driver:5.0.0'
40+
implementation 'com.bettercloud:vault-java-driver:5.1.0'
5241
}
5342
```
5443

@@ -57,7 +46,7 @@ Maven:
5746
<dependency>
5847
<groupId>com.bettercloud</groupId>
5948
<artifactId>vault-java-driver</artifactId>
60-
<version>5.0.0</version>
49+
<version>5.1.0</version>
6150
</dependency>
6251
```
6352

@@ -124,6 +113,22 @@ for both K/V versions.
124113
but leave the map `null`. Note that this option requires your authentication credentials to have access to read Vault's `/v1/sys/mounts`
125114
path.
126115

116+
Version 2 of the K/V engine dynamically injects a qualifier element into your secret paths, which varies depending on the type of for read and write operations, in between the root version
117+
operation. For example, for read and write operations, the secret path:
118+
119+
```v1/mysecret```
120+
121+
... has a "data" qualifier injected:
122+
123+
```v1/data/mysecret```
124+
125+
The default behavior of this driver is to insert the appropriate qualifier one level deep (i.e. in between the root version number
126+
and the rest of the path). However, if your secret path is prefixed, such that the qualifier should be injected further down:
127+
128+
```v1/my/long/prefix/data/anything/else```
129+
130+
... then you should accordingly set the `VaultConfig.prefixPathDepth` property when constructing your `Vault` instance.
131+
127132

128133
SSL Config
129134
----------
@@ -266,7 +271,11 @@ Note that changes to the major version (i.e. the first number) represent possibl
266271
may require modifications in your code to migrate. Changes to the minor version (i.e. the second number)
267272
should represent non-breaking changes. The third number represents any very minor bugfix patches.
268273

269-
* **5.0.0 (IN PROGRESS)**: This release contains the following updates:
274+
* **5.1.0 (IN PROGRESS)**: This release contains the following updates:
275+
* Supports path prefixes when using K/V engine V2. [(PR #189)](https://github.com/BetterCloud/vault-java-driver/pull/189)
276+
* Support all options for the createToken operation. [(PR # 199)](https://github.com/BetterCloud/vault-java-driver/pull/199)
277+
278+
* **5.0.0**: This release contains the following updates:
270279
* Changes the retry behavior, to no longer attempt retries on 4xx response codes (for which retries generally won't succeed anyway). This
271280
is the only (mildly) breaking change in this release, necessitating a major version bump. [(PR #176)](https://github.com/BetterCloud/vault-java-driver/pull/176)
272281
* Implements support for the Database secret engine. [(PR #175)](https://github.com/BetterCloud/vault-java-driver/pull/175)

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ apply plugin: 'checkstyle'
55

66
group 'com.bettercloud'
77
archivesBaseName = 'vault-java-driver'
8-
version '5.0.0'
8+
version '5.1.0-SNAPSHOT'
99
ext.isReleaseVersion = !version.endsWith('SNAPSHOT')
1010

1111
// This project is actually limited to Java 8 compatibility. See below.
@@ -19,7 +19,7 @@ repositories {
1919
dependencies {
2020
testCompile('junit:junit:4.12')
2121
testCompile('org.mockito:mockito-core:2.28.2')
22-
testCompile('org.testcontainers:testcontainers:1.12.0')
22+
testCompile('org.testcontainers:testcontainers:1.12.3')
2323
testCompile('org.eclipse.jetty:jetty-server:9.4.19.v20190610')
2424
testCompile('org.slf4j:slf4j-api:1.7.26')
2525
testCompile('org.bouncycastle:bcprov-jdk15on:1.62')

src/main/java/com/bettercloud/vault/VaultConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ public VaultConfig readTimeout(final Integer readTimeout) {
211211
/**
212212
* <p>Set the "path depth" of the prefix path. Normally this is just
213213
* 1, to correspond to one path element in the prefix path. To use
214-
* a longer prefix path, set this value
214+
* a longer prefix path, set this value.</p>
215215
*
216-
* @param prefixPathDepth integer number of path elements in the prefix path
216+
* @param pathLength integer number of path elements in the prefix path
217217
*/
218218
public VaultConfig prefixPathDepth(int prefixPathDepth) {
219219
if (prefixPathDepth < 1) {

src/main/java/com/bettercloud/vault/api/Auth.java

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ public static class TokenRequest implements Serializable {
4747
private String displayName;
4848
private Long numUses;
4949
private String role;
50+
private Boolean renewable;
51+
private String type;
52+
private String explicitMaxTtl;
53+
private String period;
54+
private String entityAlias;
5055

5156
/**
5257
* @param id (optional) The ID of the client token. Can only be specified by a root token. Otherwise, the token ID is a randomly generated UUID.
@@ -129,6 +134,57 @@ public TokenRequest role(final String role) {
129134
return this;
130135
}
131136

137+
/**
138+
* @param renewable Set to false to disable the ability of the token to be renewed past its
139+
* initial TTL. Setting the value to true will allow the token to be renewable up to
140+
* the system/mount maximum TTL.
141+
* @return This object, with its renewable field populated
142+
*/
143+
public TokenRequest renewable(final Boolean renewable) {
144+
this.renewable = renewable;
145+
return this;
146+
}
147+
148+
/**
149+
*
150+
* @param type The token type. Can be "batch" or "service".
151+
* @return This object, with its type field populated
152+
*/
153+
public TokenRequest type(final String type) {
154+
this.type = type;
155+
return this;
156+
}
157+
158+
/**
159+
*
160+
* @param explicitMaxTtl If set, the token will have an explicit max TTL set upon it.
161+
* @return This object, with its explicitMaxTtl field populated
162+
*/
163+
public TokenRequest explicitMaxTtl(final String explicitMaxTtl) {
164+
this.explicitMaxTtl = explicitMaxTtl;
165+
return this;
166+
}
167+
168+
/**
169+
*
170+
* @param period If specified, the token will be periodic
171+
* @return This object, with its period field populated
172+
*/
173+
public TokenRequest period(final String period) {
174+
this.period = period;
175+
return this;
176+
}
177+
178+
/**
179+
*
180+
* @param entityAlias Name of the entity alias to associate with during token creation.
181+
* @return This object, with its period field populated
182+
*/
183+
public TokenRequest entityAlias(final String entityAlias) {
184+
this.entityAlias = entityAlias;
185+
return this;
186+
}
187+
132188
public UUID getId() {
133189
return id;
134190
}
@@ -164,6 +220,26 @@ public Long getNumUses() {
164220
public String getRole() {
165221
return role;
166222
}
223+
224+
public Boolean getRenewable() {
225+
return renewable;
226+
}
227+
228+
public String getType() {
229+
return type;
230+
}
231+
232+
public String getExplicitMaxTtl() {
233+
return explicitMaxTtl;
234+
}
235+
236+
public String getPeriod() {
237+
return period;
238+
}
239+
240+
public String getEntityAlias() {
241+
return entityAlias;
242+
}
167243
}
168244

169245
private final VaultConfig config;
@@ -249,6 +325,11 @@ public AuthResponse createToken(final TokenRequest tokenRequest, final String to
249325
if (tokenRequest.ttl != null) jsonObject.add("ttl", tokenRequest.ttl);
250326
if (tokenRequest.displayName != null) jsonObject.add("display_name", tokenRequest.displayName);
251327
if (tokenRequest.numUses != null) jsonObject.add("num_uses", tokenRequest.numUses);
328+
if (tokenRequest.renewable != null) jsonObject.add("renewable", tokenRequest.renewable);
329+
if (tokenRequest.type != null) jsonObject.add("type", tokenRequest.type);
330+
if (tokenRequest.explicitMaxTtl != null) jsonObject.add("explicit_max_ttl", tokenRequest.explicitMaxTtl);
331+
if (tokenRequest.period != null) jsonObject.add("period", tokenRequest.period);
332+
if (tokenRequest.entityAlias != null) jsonObject.add("entity_alias", tokenRequest.entityAlias);
252333
final String requestJson = jsonObject.toString();
253334

254335
final StringBuilder urlBuilder = new StringBuilder(config.getAddress())//NOPMD

src/main/java/com/bettercloud/vault/api/Logical.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import static com.bettercloud.vault.api.LogicalUtilities.adjustPathForVersionUnDelete;
2121
import static com.bettercloud.vault.api.LogicalUtilities.jsonObjectToWriteFromEngineVersion;
2222

23-
2423
/**
2524
* <p>The implementing class for Vault's core/logical operations (e.g. read, write).</p>
2625
*

0 commit comments

Comments
 (0)