9. 自定义要作为 PropertySource 公开的 secret 后端
Spring Cloud Vault 使用基于属性的配置来创建PropertySource
s 用于键值和发现的 secret 后端。
发现的后端提供VaultSecretBackendDescriptor
bean 来描述使用 secret backend 的配置状态PropertySource
.
一个SecretBackendMetadataFactory
需要创建SecretBackendMetadata
object,其中包含 path、name 和 property 转换配置。
SecretBackendMetadata
用于支持特定的PropertySource
.
您可以注册一个VaultConfigurer
进行定制。
如果您提供VaultConfigurer
.
但是,您可以使用SecretBackendConfigurer.registerDefaultKeyValueSecretBackends()
和SecretBackendConfigurer.registerDefaultDiscoveredSecretBackends()
.
public class CustomizationBean implements VaultConfigurer {
@Override
public void addSecretBackends(SecretBackendConfigurer configurer) {
configurer.add("secret/my-application");
configurer.registerDefaultKeyValueSecretBackends(false);
configurer.registerDefaultDiscoveredSecretBackends(true);
}
}
SpringApplication application = new SpringApplication(MyApplication.class);
application.addBootstrapper(VaultBootstrapper.fromConfigurer(new CustomizationBean()));