This is an automated email from the ASF dual-hosted git repository.
acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git
The following commit(s) were added to refs/heads/main by this push:
new 4a7f46316e7 CAMEL-18478 - Support Secrets Reload from Vault/Cloud
Service in camel-spring-boot
4a7f46316e7 is described below
commit 4a7f46316e7f9f00e920593cb1cda9f10e381d4a
Author: Andrea Cosentino <[email protected]>
AuthorDate: Wed Sep 7 18:19:21 2022 +0200
CAMEL-18478 - Support Secrets Reload from Vault/Cloud Service in
camel-spring-boot
---
.../src/main/docs/spring-boot.json | 20 +++++++++++
.../boot/vault/AwsVaultAutoConfiguration.java | 3 ++
.../vault/AwsVaultConfigurationProperties.java | 39 ++++++++++++++++++++++
.../boot/vault/AwsVaultConfigurationTest.java | 9 ++++-
4 files changed, 70 insertions(+), 1 deletion(-)
diff --git a/core/camel-spring-boot/src/main/docs/spring-boot.json
b/core/camel-spring-boot/src/main/docs/spring-boot.json
index 050d6da94c9..c0338b4a39c 100644
--- a/core/camel-spring-boot/src/main/docs/spring-boot.json
+++ b/core/camel-spring-boot/src/main/docs/spring-boot.json
@@ -1373,6 +1373,20 @@
"sourceType":
"org.apache.camel.spring.boot.vault.AwsVaultConfigurationProperties",
"defaultValue": false
},
+ {
+ "name": "camel.vault.aws.refresh-enabled",
+ "type": "java.lang.Boolean",
+ "description": "Define if we want to refresh the secrets on update",
+ "sourceType":
"org.apache.camel.spring.boot.vault.AwsVaultConfigurationProperties",
+ "defaultValue": false
+ },
+ {
+ "name": "camel.vault.aws.refresh-period",
+ "type": "java.lang.Long",
+ "description": "Define the refresh period",
+ "sourceType":
"org.apache.camel.spring.boot.vault.AwsVaultConfigurationProperties",
+ "defaultValue": 30000
+ },
{
"name": "camel.vault.aws.region",
"type": "java.lang.String",
@@ -1385,6 +1399,12 @@
"description": "The AWS secret key",
"sourceType":
"org.apache.camel.spring.boot.vault.AwsVaultConfigurationProperties"
},
+ {
+ "name": "camel.vault.aws.secrets",
+ "type": "java.lang.String",
+ "description": "Define the secrets to look at",
+ "sourceType":
"org.apache.camel.spring.boot.vault.AwsVaultConfigurationProperties"
+ },
{
"name": "camel.vault.azure.client-id",
"type": "java.lang.String",
diff --git
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AwsVaultAutoConfiguration.java
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AwsVaultAutoConfiguration.java
index 68971269c25..20d3eeac81a 100644
---
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AwsVaultAutoConfiguration.java
+++
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AwsVaultAutoConfiguration.java
@@ -37,6 +37,9 @@ public class AwsVaultAutoConfiguration {
answer.setSecretKey(config.getSecretKey());
answer.setRegion(config.getRegion());
answer.setDefaultCredentialsProvider(config.isDefaultCredentialsProvider());
+ answer.setRefreshEnabled(config.isRefreshEnabled());
+ answer.setRefreshPeriod(config.getRefreshPeriod());
+ answer.setSecrets(config.getSecrets());
return answer;
}
diff --git
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AwsVaultConfigurationProperties.java
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AwsVaultConfigurationProperties.java
index f8dec601305..9657d044321 100644
---
a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AwsVaultConfigurationProperties.java
+++
b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/AwsVaultConfigurationProperties.java
@@ -41,6 +41,21 @@ public class AwsVaultConfigurationProperties {
*/
private boolean defaultCredentialsProvider;
+ /**
+ * Define if we want to refresh the secrets on update
+ */
+ private boolean refreshEnabled;
+
+ /**
+ * Define the refresh period
+ */
+ private long refreshPeriod = 30000;
+
+ /**
+ * Define the secrets to look at
+ */
+ private String secrets;
+
public String getAccessKey() {
return accessKey;
}
@@ -72,4 +87,28 @@ public class AwsVaultConfigurationProperties {
public void setDefaultCredentialsProvider(boolean
defaultCredentialsProvider) {
this.defaultCredentialsProvider = defaultCredentialsProvider;
}
+
+ public boolean isRefreshEnabled() {
+ return refreshEnabled;
+ }
+
+ public void setRefreshEnabled(boolean refreshEnabled) {
+ this.refreshEnabled = refreshEnabled;
+ }
+
+ public long getRefreshPeriod() {
+ return refreshPeriod;
+ }
+
+ public void setRefreshPeriod(long refreshPeriod) {
+ this.refreshPeriod = refreshPeriod;
+ }
+
+ public String getSecrets() {
+ return secrets;
+ }
+
+ public void setSecrets(String secrets) {
+ this.secrets = secrets;
+ }
}
diff --git
a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/AwsVaultConfigurationTest.java
b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/AwsVaultConfigurationTest.java
index 31ab8844aec..8df230702a5 100644
---
a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/AwsVaultConfigurationTest.java
+++
b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/AwsVaultConfigurationTest.java
@@ -35,7 +35,11 @@ import org.springframework.test.annotation.DirtiesContext;
"camel.vault.aws.accessKey=myAccessKey",
"camel.vault.aws.secretKey=mySecretKey",
"camel.vault.aws.region=myRegion",
- "camel.vault.aws.defaultCredentialsProvider=true"}
+ "camel.vault.aws.defaultCredentialsProvider=true",
+ "camel.vault.aws.refreshPeriod=60000",
+ "camel.vault.aws.refreshEnabled=true",
+ "camel.vault.aws.secrets=supersecret"
+ }
)
public class AwsVaultConfigurationTest {
@@ -48,5 +52,8 @@ public class AwsVaultConfigurationTest {
Assertions.assertEquals("mySecretKey",
camelContext.getVaultConfiguration().aws().getSecretKey());
Assertions.assertEquals("myRegion",
camelContext.getVaultConfiguration().aws().getRegion());
Assertions.assertEquals(true,
camelContext.getVaultConfiguration().aws().isDefaultCredentialsProvider());
+ Assertions.assertEquals(true,
camelContext.getVaultConfiguration().aws().isRefreshEnabled());
+ Assertions.assertEquals(60000,
camelContext.getVaultConfiguration().aws().getRefreshPeriod());
+ Assertions.assertEquals("supersecret",
camelContext.getVaultConfiguration().aws().getSecrets());
}
}