Skip to content

deprecate optionalHeader #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/com/bettercloud/vault/Vault.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ private Map<String, String> collectSecretEngineVersions() {
try {
final RestResponse restResponse = new Rest()//NOPMD
.url(vaultConfig.getAddress() + "/v1/sys/mounts")
.optionalHeader("X-Vault-Token", vaultConfig.getToken())
.optionalHeader("X-Vault-Namespace", this.vaultConfig.getNameSpace())
.header("X-Vault-Token", vaultConfig.getToken())
.header("X-Vault-Namespace", this.vaultConfig.getNameSpace())
.connectTimeoutSeconds(vaultConfig.getOpenTimeout())
.readTimeoutSeconds(vaultConfig.getReadTimeout())
.sslVerification(vaultConfig.getSslConfig().isVerify())
Expand Down
40 changes: 20 additions & 20 deletions src/main/java/com/bettercloud/vault/api/Auth.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ public AuthResponse createToken(final TokenRequest tokenRequest, final String to
// HTTP request to Vault
final RestResponse restResponse = new Rest()//NOPMD
.url(url)
.optionalHeader("X-Vault-Token", config.getToken())
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Token", config.getToken())
.header("X-Vault-Namespace", this.nameSpace)
.body(requestJson.getBytes(StandardCharsets.UTF_8))
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
Expand Down Expand Up @@ -422,7 +422,7 @@ public AuthResponse loginByAppRole(final String path, final String roleId, final
final String requestJson = Json.object().add("role_id", roleId).add("secret_id", secretId).toString();
final RestResponse restResponse = new Rest()//NOPMD
.url(config.getAddress() + "/v1/auth/" + path + "/login")
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Namespace", this.nameSpace)
.body(requestJson.getBytes(StandardCharsets.UTF_8))
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
Expand Down Expand Up @@ -505,7 +505,7 @@ public AuthResponse loginByUserPass(final String username, final String password
final String requestJson = Json.object().add("password", password).toString();
final RestResponse restResponse = new Rest()//NOPMD
.url(config.getAddress() + "/v1/auth/" + mount + "/login/" + username)
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Namespace", this.nameSpace)
.body(requestJson.getBytes(StandardCharsets.UTF_8))
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
Expand Down Expand Up @@ -628,7 +628,7 @@ public AuthResponse loginByAwsEc2(final String role, final String identity, fina
final RestResponse restResponse = new Rest()//NOPMD
.url(config.getAddress() + "/v1/auth/" + mount + "/login")
.body(requestJson.getBytes(StandardCharsets.UTF_8))
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Namespace", this.nameSpace)
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
.sslVerification(config.getSslConfig().isVerify())
Expand Down Expand Up @@ -703,7 +703,7 @@ public AuthResponse loginByAwsEc2(final String role, final String pkcs7, final S
final String requestJson = request.toString();
final RestResponse restResponse = new Rest()//NOPMD
.url(config.getAddress() + "/v1/auth/" + mount + "/login")
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Namespace", this.nameSpace)
.body(requestJson.getBytes(StandardCharsets.UTF_8))
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
Expand Down Expand Up @@ -782,7 +782,7 @@ public AuthResponse loginByAwsIam(final String role, final String iamRequestUrl,
final String requestJson = request.toString();
final RestResponse restResponse = new Rest()//NOPMD
.url(config.getAddress() + "/v1/auth/" + mount + "/login")
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Namespace", this.nameSpace)
.body(requestJson.getBytes(StandardCharsets.UTF_8))
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
Expand Down Expand Up @@ -867,7 +867,7 @@ public AuthResponse loginByGithub(final String githubToken, final String githubA
final String requestJson = Json.object().add("token", githubToken).toString();
final RestResponse restResponse = new Rest()//NOPMD
.url(config.getAddress() + "/v1/auth/" + mount + "/login")
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Namespace", this.nameSpace)
.body(requestJson.getBytes(StandardCharsets.UTF_8))
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
Expand Down Expand Up @@ -931,7 +931,7 @@ public AuthResponse loginByJwt(final String provider, final String role, final S
final String requestJson = Json.object().add("role", role).add("jwt", jwt).toString();
final RestResponse restResponse = new Rest()
.url(config.getAddress() + "/v1/auth/" + provider + "/login")
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Namespace", this.nameSpace)
.body(requestJson.getBytes(StandardCharsets.UTF_8))
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
Expand Down Expand Up @@ -1071,7 +1071,7 @@ public AuthResponse loginByCert(final String certAuthMount) throws VaultExceptio
try {
final RestResponse restResponse = new Rest()//NOPMD
.url(config.getAddress() + "/v1/auth/" + mount + "/login")
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Namespace", this.nameSpace)
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
.sslVerification(config.getSslConfig().isVerify())
Expand Down Expand Up @@ -1152,8 +1152,8 @@ public AuthResponse renewSelf(final long increment, final String tokenAuthMount)
final String requestJson = Json.object().add("increment", increment).toString();
final RestResponse restResponse = new Rest()//NOPMD
.url(config.getAddress() + "/v1/auth/" + mount + "/renew-self")
.optionalHeader("X-Vault-Token", config.getToken())
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Token", config.getToken())
.header("X-Vault-Namespace", this.nameSpace)
.body(increment < 0 ? null : requestJson.getBytes(StandardCharsets.UTF_8))
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
Expand Down Expand Up @@ -1215,8 +1215,8 @@ public LookupResponse lookupSelf(final String tokenAuthMount) throws VaultExcept
// HTTP request to Vault
final RestResponse restResponse = new Rest()//NOPMD
.url(config.getAddress() + "/v1/auth/" + mount + "/lookup-self")
.optionalHeader("X-Vault-Token", config.getToken())
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Token", config.getToken())
.header("X-Vault-Namespace", this.nameSpace)
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
.sslVerification(config.getSslConfig().isVerify())
Expand Down Expand Up @@ -1277,8 +1277,8 @@ public LogicalResponse lookupWrap() throws VaultException {
// HTTP request to Vault
final RestResponse restResponse = new Rest()//NOPMD
.url(config.getAddress() + "/v1/sys/wrapping/lookup")
.optionalHeader("X-Vault-Token", config.getToken())
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Token", config.getToken())
.header("X-Vault-Namespace", this.nameSpace)
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
.sslVerification(config.getSslConfig().isVerify())
Expand Down Expand Up @@ -1339,8 +1339,8 @@ public void revokeSelf(final String tokenAuthMount) throws VaultException {
// HTTP request to Vault
final RestResponse restResponse = new Rest()//NOPMD
.url(config.getAddress() + "/v1/auth/" + mount + "/revoke-self")
.optionalHeader("X-Vault-Token", config.getToken())
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Token", config.getToken())
.header("X-Vault-Namespace", this.nameSpace)
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
.sslVerification(config.getSslConfig().isVerify())
Expand Down Expand Up @@ -1440,8 +1440,8 @@ public AuthResponse unwrap(final String wrappedToken) throws VaultException {
// HTTP request to Vault
final RestResponse restResponse = new Rest()
.url(url)
.optionalHeader("X-Vault-Token", config.getToken())
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Token", config.getToken())
.header("X-Vault-Namespace", this.nameSpace)
.body(requestJson.getBytes(StandardCharsets.UTF_8))
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/bettercloud/vault/api/Debug.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,12 @@ public HealthResponse health(
// Build an HTTP request for Vault
final Rest rest = new Rest()//NOPMD
.url(config.getAddress() + "/v1/" + path)
.header("X-Vault-Token", config.getToken())
.header("X-Vault-Namespace", this.nameSpace)
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
.sslVerification(config.getSslConfig().isVerify())
.sslContext(config.getSslConfig().getSslContext());
// Add token if present
rest.optionalHeader("X-Vault-Token", config.getToken());
rest.optionalHeader("X-Vault-Namespace", this.nameSpace);
// Add params if present
if (standbyOk != null) rest.parameter("standbyok", standbyOk.toString());
if (activeCode != null) rest.parameter("activecode", activeCode.toString());
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/bettercloud/vault/api/Leases.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ public VaultResponse revoke(final String leaseId) throws VaultException {
*/
final RestResponse restResponse = new Rest()//NOPMD
.url(config.getAddress() + "/v1/sys/leases/revoke/" + leaseId)
.optionalHeader("X-Vault-Token", config.getToken())
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Token", config.getToken())
.header("X-Vault-Namespace", this.nameSpace)
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
.sslVerification(config.getSslConfig().isVerify())
Expand Down Expand Up @@ -117,8 +117,8 @@ public VaultResponse revokePrefix(final String prefix) throws VaultException {
try {
final RestResponse restResponse = new Rest()//NOPMD
.url(config.getAddress() + "/v1/sys/revoke-prefix/" + prefix)
.optionalHeader("X-Vault-Token", config.getToken())
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Token", config.getToken())
.header("X-Vault-Namespace", this.nameSpace)
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
.sslVerification(config.getSslConfig().isVerify())
Expand Down Expand Up @@ -175,8 +175,8 @@ public VaultResponse revokeForce(final String prefix) throws VaultException {
try {
final RestResponse restResponse = new Rest()//NOPMD
.url(config.getAddress() + "/v1/sys/revoke-force/" + prefix)
.optionalHeader("X-Vault-Token", config.getToken())
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Token", config.getToken())
.header("X-Vault-Namespace", this.nameSpace)
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
.sslVerification(config.getSslConfig().isVerify())
Expand Down Expand Up @@ -238,8 +238,8 @@ public VaultResponse renew(final String leaseId, final long increment) throws Va
final String requestJson = Json.object().add("increment", increment).toString();
final RestResponse restResponse = new Rest()//NOPMD
.url(config.getAddress() + "/v1/sys/renew/" + leaseId)
.optionalHeader("X-Vault-Token", config.getToken())
.optionalHeader("X-Vault-Namespace", this.nameSpace)
.header("X-Vault-Token", config.getToken())
.header("X-Vault-Namespace", this.nameSpace)
.body(increment < 0 ? null : requestJson.getBytes(StandardCharsets.UTF_8))
.connectTimeoutSeconds(config.getOpenTimeout())
.readTimeoutSeconds(config.getReadTimeout())
Expand Down
Loading