Add support for Vault's database backend.

We now support Vault's database backend directly. MySQL and PostgreSQL configuration properties are deprecated now in favor of spring.cloud.vault.database. Cassandra and MongoDB backends remain active and default to their deprecated backends to support multi-database configuration of multiple, various database types.

spring.cloud.vault:
    database:
        enabled: true
        role: readonly

Original pull request: gh-170.
Related ticket: gh-169.
This commit is contained in:
Per Abich
2017-10-22 13:15:54 +01:00
committed by Mark Paluch
parent 9cff9eb9ed
commit 9da5e83dc9
4 changed files with 114 additions and 6 deletions

View File

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

View File

@@ -0,0 +1,61 @@
/*
* Copyright 2016 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
*
* 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 org.springframework.cloud.vault.config.databases;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotEmpty;
/**
* Configuration properties for Vault using the Database integration.
*
* @author Per Abich
*/
@ConfigurationProperties("spring.cloud.vault.database")
@Data
@Validated
public class VaultDatabaseProperties implements DatabaseSecretProperties {
/**
* Enable database backend usage.
*/
private boolean enabled = false;
/**
* Role name for credentials.
*/
private String role;
/**
* Database backend path.
*/
@NotEmpty
private String backend = "database";
/**
* Target property for the obtained username.
*/
@NotEmpty
private String usernameProperty = "spring.datasource.username";
/**
* Target property for the obtained password.
*/
@NotEmpty
private String passwordProperty = "spring.datasource.password";
}

View File

@@ -15,13 +15,12 @@
*/
package org.springframework.cloud.vault.config.databases;
import javax.validation.constraints.NotEmpty;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotEmpty;
/**
* Configuration properties for Vault using the PostgreSQL integration.
*