You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2022/07/14 12:56:45 UTC

[camel-spring-boot] branch main updated (9c8ca0e411b -> 186b4f27100)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git


    from 9c8ca0e411b Sync and regen
     new 7aa43bc45b1 CAMEL-17688 - Support ability to load properties from Vault/Secrets cloud services - Hashicorp Vault
     new 186b4f27100 CAMEL-17688 - Support ability to load properties from Vault/Secrets cloud services - Hashicorp Vault

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/main/docs/spring-boot.json                 | 35 +++++++++
 ...n.java => HashicorpVaultAutoConfiguration.java} | 19 ++---
 .../HashicorpVaultConfigurationProperties.java     | 88 ++++++++++++++++++++++
 .../src/main/resources/META-INF/spring.factories   |  3 +-
 ...t.java => HashicorpVaultConfigurationTest.java} | 23 +++---
 5 files changed, 148 insertions(+), 20 deletions(-)
 copy core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/{GcpVaultAutoConfiguration.java => HashicorpVaultAutoConfiguration.java} (70%)
 create mode 100644 core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/HashicorpVaultConfigurationProperties.java
 copy core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/{AwsVaultConfigurationTest.java => HashicorpVaultConfigurationTest.java} (62%)


[camel-spring-boot] 02/02: CAMEL-17688 - Support ability to load properties from Vault/Secrets cloud services - Hashicorp Vault

Posted by ac...@apache.org.
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

commit 186b4f2710063468ede55a70d2d404f0e9ec1181
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jul 14 14:42:51 2022 +0200

    CAMEL-17688 - Support ability to load properties from Vault/Secrets cloud services - Hashicorp Vault
---
 .../src/main/docs/spring-boot.json                 | 35 +++++++++
 .../vault/HashicorpVaultAutoConfiguration.java     | 44 +++++++++++
 .../HashicorpVaultConfigurationProperties.java     | 88 ++++++++++++++++++++++
 .../vault/HashicorpVaultConfigurationTest.java     | 55 ++++++++++++++
 4 files changed, 222 insertions(+)

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 828a160791a..a6d7dd8d232 100644
--- a/core/camel-spring-boot/src/main/docs/spring-boot.json
+++ b/core/camel-spring-boot/src/main/docs/spring-boot.json
@@ -129,6 +129,11 @@
       "type": "org.apache.camel.spring.boot.vault.GcpVaultConfigurationProperties",
       "sourceType": "org.apache.camel.spring.boot.vault.GcpVaultConfigurationProperties"
     },
+    {
+      "name": "camel.vault.hashicorp",
+      "type": "org.apache.camel.spring.boot.vault.HashicorpVaultConfigurationProperties",
+      "sourceType": "org.apache.camel.spring.boot.vault.HashicorpVaultConfigurationProperties"
+    },
     {
       "name": "management.endpoint.camel",
       "type": "org.apache.camel.spring.boot.actuate.console.CamelDevConsoleEndpoint",
@@ -1410,6 +1415,36 @@
       "sourceType": "org.apache.camel.spring.boot.vault.GcpVaultConfigurationProperties",
       "defaultValue": false
     },
+    {
+      "name": "camel.vault.hashicorp.engine",
+      "type": "java.lang.String",
+      "description": "The Hashicorp Vault Engine for accessing secrets",
+      "sourceType": "org.apache.camel.spring.boot.vault.HashicorpVaultConfigurationProperties"
+    },
+    {
+      "name": "camel.vault.hashicorp.host",
+      "type": "java.lang.String",
+      "description": "The Hashicorp Vault Host for accessing the service",
+      "sourceType": "org.apache.camel.spring.boot.vault.HashicorpVaultConfigurationProperties"
+    },
+    {
+      "name": "camel.vault.hashicorp.port",
+      "type": "java.lang.String",
+      "description": "The Hashicorp Vault port for accessing the service",
+      "sourceType": "org.apache.camel.spring.boot.vault.HashicorpVaultConfigurationProperties"
+    },
+    {
+      "name": "camel.vault.hashicorp.scheme",
+      "type": "java.lang.String",
+      "description": "The Hashicorp Vault Scheme for accessing the service",
+      "sourceType": "org.apache.camel.spring.boot.vault.HashicorpVaultConfigurationProperties"
+    },
+    {
+      "name": "camel.vault.hashicorp.token",
+      "type": "java.lang.String",
+      "description": "The Hashicorp Vault Token for accessing the service",
+      "sourceType": "org.apache.camel.spring.boot.vault.HashicorpVaultConfigurationProperties"
+    },
     {
       "name": "management.endpoint.camel.cache.time-to-live",
       "type": "java.time.Duration",
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/HashicorpVaultAutoConfiguration.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/HashicorpVaultAutoConfiguration.java
new file mode 100644
index 00000000000..a5f50df3191
--- /dev/null
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/HashicorpVaultAutoConfiguration.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.camel.spring.boot.vault;
+
+import org.apache.camel.spring.boot.CamelAutoConfiguration;
+import org.apache.camel.vault.HashicorpVaultConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration(proxyBeanMethods = false)
+@ConditionalOnBean(CamelAutoConfiguration.class)
+@EnableConfigurationProperties(HashicorpVaultConfigurationProperties.class)
+@AutoConfigureAfter(CamelAutoConfiguration.class)
+public class HashicorpVaultAutoConfiguration {
+
+    @Bean
+    public HashicorpVaultConfiguration hashicorpVaultConfiguration(HashicorpVaultConfigurationProperties config) {
+        HashicorpVaultConfiguration answer = new HashicorpVaultConfiguration();
+        answer.setToken(config.getToken());
+        answer.setEngine(config.getEngine());
+        answer.setHost(config.getHost());
+        answer.setPort(config.getPort());
+        answer.setScheme(config.getScheme());
+        return answer;
+    }
+
+}
diff --git a/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/HashicorpVaultConfigurationProperties.java b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/HashicorpVaultConfigurationProperties.java
new file mode 100644
index 00000000000..08e61edfc67
--- /dev/null
+++ b/core/camel-spring-boot/src/main/java/org/apache/camel/spring/boot/vault/HashicorpVaultConfigurationProperties.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.camel.spring.boot.vault;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+@ConfigurationProperties(prefix = "camel.vault.hashicorp")
+public class HashicorpVaultConfigurationProperties {
+
+    /**
+     * The Hashicorp Vault Token for accessing the service
+     */
+    private String token;
+
+    /**
+     * The Hashicorp Vault Engine for accessing secrets
+     */
+    private String engine;
+
+    /**
+     * The Hashicorp Vault Host for accessing the service
+     */
+    private String host;
+
+    /**
+     * The Hashicorp Vault port for accessing the service
+     */
+    private String port;
+
+    /**
+     * The Hashicorp Vault Scheme for accessing the service
+     */
+    private String scheme;
+
+    public String getToken() {
+        return token;
+    }
+
+    public void setToken(String token) {
+        this.token = token;
+    }
+
+    public String getEngine() {
+        return engine;
+    }
+
+    public void setEngine(String engine) {
+        this.engine = engine;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    public String getPort() {
+        return port;
+    }
+
+    public void setPort(String port) {
+        this.port = port;
+    }
+
+    public String getScheme() {
+        return scheme;
+    }
+
+    public void setScheme(String scheme) {
+        this.scheme = scheme;
+    }
+}
diff --git a/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/HashicorpVaultConfigurationTest.java b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/HashicorpVaultConfigurationTest.java
new file mode 100644
index 00000000000..df91ce61130
--- /dev/null
+++ b/core/camel-spring-boot/src/test/java/org/apache/camel/spring/boot/vault/HashicorpVaultConfigurationTest.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.camel.spring.boot.vault;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.test.spring.junit5.CamelSpringBootTest;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.DirtiesContext;
+
+@DirtiesContext
+@CamelSpringBootTest
+@EnableAutoConfiguration
+@SpringBootTest(
+        classes = {
+                HashicorpVaultConfigurationTest.class},
+        properties = {
+                "camel.vault.hashicorp.token=myToken",
+                "camel.vault.hashicorp.engine=myEngine",
+                "camel.vault.hashicorp.host=myHost",
+                "camel.vault.hashicorp.port=myPort",
+                "camel.vault.hashicorp.scheme=myScheme"
+        }
+)
+public class HashicorpVaultConfigurationTest {
+
+    @Autowired
+    private CamelContext camelContext;
+
+    @Test
+    public void testAwsVault() throws Exception {
+        Assertions.assertEquals("myToken", camelContext.getVaultConfiguration().hashicorp().getToken());
+        Assertions.assertEquals("myEngine", camelContext.getVaultConfiguration().hashicorp().getEngine());
+        Assertions.assertEquals("myHost", camelContext.getVaultConfiguration().hashicorp().getHost());
+        Assertions.assertEquals("myPort", camelContext.getVaultConfiguration().hashicorp().getPort());
+        Assertions.assertEquals("myScheme", camelContext.getVaultConfiguration().hashicorp().getScheme());
+    }
+}


[camel-spring-boot] 01/02: CAMEL-17688 - Support ability to load properties from Vault/Secrets cloud services - Hashicorp Vault

Posted by ac...@apache.org.
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

commit 7aa43bc45b190fdd42bc4be8c03364ca662e737a
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Jul 14 13:25:38 2022 +0200

    CAMEL-17688 - Support ability to load properties from Vault/Secrets cloud services - Hashicorp Vault
---
 core/camel-spring-boot/src/main/resources/META-INF/spring.factories | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/core/camel-spring-boot/src/main/resources/META-INF/spring.factories b/core/camel-spring-boot/src/main/resources/META-INF/spring.factories
index e43ce29074f..8819f21b892 100644
--- a/core/camel-spring-boot/src/main/resources/META-INF/spring.factories
+++ b/core/camel-spring-boot/src/main/resources/META-INF/spring.factories
@@ -34,5 +34,6 @@ org.apache.camel.spring.boot.threadpool.CamelThreadPoolAutoConfiguration,\
 org.apache.camel.spring.boot.routetemplate.CamelRouteTemplateAutoConfiguration,\
 org.apache.camel.spring.boot.vault.AwsVaultAutoConfiguration, \
 org.apache.camel.spring.boot.vault.GcpVaultAutoConfiguration, \
-org.apache.camel.spring.boot.vault.AzureVaultAutoConfiguration
+org.apache.camel.spring.boot.vault.AzureVaultAutoConfiguration, \
+org.apache.camel.spring.boot.vault.HashicorpVaultAutoConfiguration