Database support for Elasticsearch

Spring Cloud Vault can now obtain credentials for Elasticsearch's HTTP API by enabling vault.config.backends.elasticsearch.enabled=true and providing a role name.

Closes gh-392.
This commit is contained in:
Mark Paluch
2020-05-20 14:51:58 +02:00
parent 0f7b9ec7fc
commit 0ea68bad57
4 changed files with 277 additions and 1 deletions

View File

@@ -41,7 +41,8 @@ import org.springframework.vault.core.util.PropertyTransformer;
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties({ VaultMySqlProperties.class,
VaultPostgreSqlProperties.class, VaultCassandraProperties.class,
VaultMongoProperties.class, VaultDatabaseProperties.class })
VaultMongoProperties.class, VaultElasticsearchProperties.class,
VaultDatabaseProperties.class })
public class VaultConfigDatabaseBootstrapConfiguration {
@Bean

View File

@@ -0,0 +1,121 @@
/*
* Copyright 2016-2020 the original author or authors.
*
* 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
*
* https://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 org.springframework.cloud.vault.config.databases;
import javax.validation.constraints.NotEmpty;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
/**
* Configuration properties for Vault using the Elasticsearch integration.
*
* @author Mark Paluch
* @since 3.0
*/
@ConfigurationProperties("spring.cloud.vault.elasticsearch")
@Validated
public class VaultElasticsearchProperties implements DatabaseSecretProperties {
/**
* Enable elasticsearch backend usage.
*/
private boolean enabled = false;
/**
* Role name for credentials.
*/
private String role;
/**
* Enable static role usage.
*/
private boolean staticRole = false;
/**
* Database backend path.
*/
@NotEmpty
private String backend = "database";
/**
* Target property for the obtained username.
*/
@NotEmpty
private String usernameProperty = "spring.elasticsearch.rest.username";
/**
* Target property for the obtained password.
*/
@NotEmpty
private String passwordProperty = "spring.elasticsearch.rest.password";
@Override
public boolean isEnabled() {
return this.enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
@Override
public String getRole() {
return this.role;
}
public void setRole(String role) {
this.role = role;
}
@Override
public boolean isStaticRole() {
return this.staticRole;
}
public void setStaticRole(boolean staticRole) {
this.staticRole = staticRole;
}
@Override
public String getBackend() {
return this.backend;
}
public void setBackend(String backend) {
this.backend = backend;
}
@Override
public String getUsernameProperty() {
return this.usernameProperty;
}
public void setUsernameProperty(String usernameProperty) {
this.usernameProperty = usernameProperty;
}
@Override
public String getPasswordProperty() {
return this.passwordProperty;
}
public void setPasswordProperty(String passwordProperty) {
this.passwordProperty = passwordProperty;
}
}