22 lines
4.9 KiB
HTML
22 lines
4.9 KiB
HTML
<html><head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
|
<title>97. Configure PropertySourceLocator behavior</title><link rel="stylesheet" type="text/css" href="css/manual-multipage.css"><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="multi_spring-cloud.html" title="Spring Cloud"><link rel="up" href="multi__spring_cloud_vault.html" title="Part XIII. Spring Cloud Vault"><link rel="prev" href="multi_vault.config.backends.database-backends.html" title="96. Database backends"><link rel="next" href="multi__service_registry_configuration.html" title="98. Service Registry Configuration"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">97. Configure <code class="literal">PropertySourceLocator</code> behavior</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="multi_vault.config.backends.database-backends.html">Prev</a> </td><th width="60%" align="center">Part XIII. Spring Cloud Vault</th><td width="20%" align="right"> <a accesskey="n" href="multi__service_registry_configuration.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h2 class="title"><a name="vault.config.backends.configurer" href="#vault.config.backends.configurer"></a>97. Configure <code class="literal">PropertySourceLocator</code> behavior</h2></div></div></div><p>Spring Cloud Vault uses property-based configuration to create <code class="literal">PropertySource</code>s
|
|
for generic and discovered secret backends.</p><p>Discovered backends provide <code class="literal">VaultSecretBackendDescriptor</code> beans to describe the configuration
|
|
state to use secret backend as <code class="literal">PropertySource</code>. A <code class="literal">SecretBackendMetadataFactory</code> is required
|
|
to create a <code class="literal">SecretBackendMetadata</code> object which contains path, name and property transformation
|
|
configuration.</p><p><code class="literal">SecretBackendMetadata</code> is used to back a particular <code class="literal">PropertySource</code>.</p><p>You can register an arbitrary number of beans implementing <code class="literal">VaultConfigurer</code> for customization.
|
|
Default generic and discovered backend registration is disabled if Spring Cloud Vault discovers
|
|
at least one <code class="literal">VaultConfigurer</code> bean. You can however enable default registration with
|
|
<code class="literal">SecretBackendConfigurer.registerDefaultGenericSecretBackends()</code> and <code class="literal">SecretBackendConfigurer.registerDefaultDiscoveredSecretBackends()</code>.</p><div class="informalexample"><pre class="programlisting"><span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">class</span> CustomizationBean <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">implements</span> VaultConfigurer {
|
|
|
|
<em><span class="hl-annotation" style="color: gray">@Override</span></em>
|
|
<span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">public</span> <span xmlns:d="http://docbook.org/ns/docbook" class="hl-keyword">void</span> addSecretBackends(SecretBackendConfigurer configurer) {
|
|
|
|
configurer.add(<span xmlns:d="http://docbook.org/ns/docbook" class="hl-string">"secret/my-application"</span>);
|
|
|
|
configurer.registerDefaultGenericSecretBackends(false);
|
|
configurer.registerDefaultDiscoveredSecretBackends(true);
|
|
}
|
|
}</pre></div><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note"><tr><td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td><th align="left">Note</th></tr><tr><td align="left" valign="top"><p>All customization is required to happen in the bootstrap context. Add your configuration
|
|
classes to <code class="literal">META-INF/spring.factories</code> at <code class="literal">org.springframework.cloud.bootstrap.BootstrapConfiguration</code>
|
|
in your application.</p></td></tr></table></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="multi_vault.config.backends.database-backends.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="multi__spring_cloud_vault.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="multi__service_registry_configuration.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">96. Database backends </td><td width="20%" align="center"><a accesskey="h" href="multi_spring-cloud.html">Home</a></td><td width="40%" align="right" valign="top"> 98. Service Registry Configuration</td></tr></table></div></body></html> |