I have this bean that supposed to deal with vault properties that came from VCAP_SERIVCES
@Configuration
@Profile("cloud")
@ConditionalOnProperty(name = "spring.cloud.vault.enabled", matchIfMissing = false)
@EnableConfigurationProperties(VaultGenericBackendProperties.class)
// @Import(VaultBootstrapConfiguration.class)
@Order(Ordered.LOWEST_PRECEDENCE - 100)
public class MultiBackendsVaultConnectorBootstrapConfiguration {
private static final Logger log =
LoggerFactory.getLogger(MultiBackendsVaultConnectorBootstrapConfiguration.class);
private static final String VERSION_BACKEND_PREFIX = "^/v1/";
@Bean
public VaultConfigurer cloudVaultConfigurer(Environment environment/*, VaultCloudProperties vaultProperties*/) {
List<SecretBackendMetadata> backends = new ArrayList<>();
String keyName = environment.getProperty("spring.cloud.vault.defaultKey");
// failed to inject VaultCloudProperties as it could not find the bean
backends.add(
GenericSecretBackendMetadata
.create(environment.getProperty("core.application.vault.service_secret_path")
.replaceAll(VERSION_BACKEND_PREFIX, ""), keyName));
backends.add(
GenericSecretBackendMetadata
.create(environment.getProperty("core.application.vault.space_secret_path")
.replaceAll(VERSION_BACKEND_PREFIX, ""), keyName));
backends.add(
GenericSecretBackendMetadata
.create(environment.getProperty("core.application.vault.org_secret_path")
.replaceAll(VERSION_BACKEND_PREFIX, ""), keyName));
return new VaultConnectorConfigurer(backends);
}
static class VaultConnectorConfigurer implements VaultConfigurer {
private final Collection<SecretBackendMetadata> backends;
VaultConnectorConfigurer(Collection<SecretBackendMetadata> backends) {
this.backends = backends;
}
@Override
public void addSecretBackends(SecretBackendConfigurer configurer) {
for (SecretBackendMetadata metadata : backends) {
configurer.add(metadata);
}
configurer.registerDefaultDiscoveredSecretBackends(true);
}
}
}
I commented VaultBootstrapConfiguration.class configuration because after moving away from connectors to cf-env it is unable instantiate clientAuthentication anymore.
But when I run the application, it tries to instantiate VaultConnectorConfigurer but fails to do that. And debug stop in VaultServiceProcessor is never being executed (just like I cannot autowire VaultCloudProperties).
I have a processor that supposed to process
vault
configuration fromVCAP_SERVICES
property.As far as I understand this env processor supposed to populate
properties
map which is Spring configuration (same as in application.yml for example).I have specified processor in
META-INF
In folder
services
the file contains a single like thisWhile another
spring.factories
contains thisI specified configuration object (to have properties in some object at least)
I have this bean that supposed to deal with vault properties that came from VCAP_SERIVCES
I commented
VaultBootstrapConfiguration.class
configuration because after moving away fromconnectors
tocf-env
it is unable instantiate clientAuthentication anymore.But when I run the application, it tries to instantiate
VaultConnectorConfigurer
but fails to do that. And debug stop inVaultServiceProcessor
is never being executed (just like I cannot autowire VaultCloudProperties).What might be the reason?