Skip to content

Commit

Permalink
Add azure-key-vault native support
Browse files Browse the repository at this point in the history
Fixes #6248
  • Loading branch information
jamesnetherton committed Jul 3, 2024
1 parent d38a17e commit 591b0aa
Show file tree
Hide file tree
Showing 21 changed files with 200 additions and 87 deletions.
6 changes: 3 additions & 3 deletions docs/modules/ROOT/examples/components/azure-key-vault.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
# This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page
cqArtifactId: camel-quarkus-azure-key-vault
cqArtifactIdBase: azure-key-vault
cqNativeSupported: false
cqStatus: Preview
cqNativeSupported: true
cqStatus: Stable
cqDeprecated: false
cqJvmSince: 2.10.0
cqNativeSince: n/a
cqNativeSince: 3.13.0
cqCamelPartName: azure-key-vault
cqCamelPartTitle: Azure Key Vault
cqCamelPartDescription: Manage secrets and keys in Azure Key Vault Service
Expand Down
21 changes: 16 additions & 5 deletions docs/modules/ROOT/pages/reference/extensions/azure-key-vault.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
= Azure Key Vault
:linkattrs:
:cq-artifact-id: camel-quarkus-azure-key-vault
:cq-native-supported: false
:cq-status: Preview
:cq-status-deprecation: Preview
:cq-native-supported: true
:cq-status: Stable
:cq-status-deprecation: Stable
:cq-description: Manage secrets and keys in Azure Key Vault Service
:cq-deprecated: false
:cq-jvm-since: 2.10.0
:cq-native-since: n/a
:cq-native-since: 3.13.0

ifeval::[{doc-show-badges} == true]
[.badges]
[.badge-key]##JVM since##[.badge-supported]##2.10.0## [.badge-key]##Native##[.badge-unsupported]##unsupported##
[.badge-key]##JVM since##[.badge-supported]##2.10.0## [.badge-key]##Native since##[.badge-supported]##3.13.0##
endif::[]

Manage secrets and keys in Azure Key Vault Service
Expand All @@ -29,6 +29,10 @@ Please refer to the above link for usage and configuration details.
[id="extensions-azure-key-vault-maven-coordinates"]
== Maven coordinates

https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-azure-key-vault[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"]

Or add the coordinates to your existing project:

[source,xml]
----
<dependency>
Expand All @@ -39,3 +43,10 @@ Please refer to the above link for usage and configuration details.
ifeval::[{doc-show-user-guide-link} == true]
Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.
endif::[]

[id="extensions-azure-key-vault-ssl-in-native-mode"]
== SSL in native mode

This extension auto-enables SSL support in native mode. Hence you do not need to add
`quarkus.ssl.native=true` to your `application.properties` yourself. See also
https://quarkus.io/guides/native-and-ssl[Quarkus SSL guide].

This file was deleted.

1 change: 0 additions & 1 deletion extensions-jvm/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
<module>aws-secrets-manager</module>
<module>aws-xray</module>
<module>azure-cosmosdb</module>
<module>azure-key-vault</module>
<module>azure-servicebus</module>
<module>azure-storage-datalake</module>
<module>barcode</module>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* 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.quarkus.component.azure.key.vault.deployment;

import java.util.Set;
import java.util.stream.Collectors;

import com.azure.json.JsonSerializable;
import com.azure.security.keyvault.secrets.implementation.SecretClientImpl;
import com.azure.security.keyvault.secrets.implementation.models.KeyVaultErrorException;
import com.microsoft.azure.proton.transport.proxy.impl.DigestProxyChallengeProcessorImpl;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import io.quarkus.deployment.builditem.IndexDependencyBuildItem;
import io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import io.quarkus.deployment.builditem.nativeimage.RuntimeInitializedClassBuildItem;
import org.jboss.jandex.ClassInfo;

class AzureKeyVaultProcessor {
private static final String FEATURE = "camel-azure-key-vault";

@BuildStep
FeatureBuildItem feature() {
return new FeatureBuildItem(FEATURE);
}

@BuildStep
ExtensionSslNativeSupportBuildItem enableNativeSslSupport() {
return new ExtensionSslNativeSupportBuildItem(FEATURE);
}

@BuildStep
IndexDependencyBuildItem indexDependencies() {
return new IndexDependencyBuildItem("com.azure", "azure-security-keyvault-secrets");
}

@BuildStep
void registerForReflection(CombinedIndexBuildItem combinedIndex, BuildProducer<ReflectiveClassBuildItem> reflectiveClass) {
Set<String> keyVaultModelClasses = combinedIndex.getIndex()
.getAllKnownImplementors(JsonSerializable.class)
.stream()
.map(ClassInfo::toString)
.filter(className -> className.startsWith("com.azure.security.keyvault"))
.collect(Collectors.toSet());

keyVaultModelClasses.add(KeyVaultErrorException.class.getName());

reflectiveClass.produce(ReflectiveClassBuildItem.builder(keyVaultModelClasses.toArray(new String[0]))
.methods(true)
.build());
}

@BuildStep
void runtimeInitializedClasses(BuildProducer<RuntimeInitializedClassBuildItem> runtimeInitializedClass) {
runtimeInitializedClass
.produce(new RuntimeInitializedClassBuildItem("com.microsoft.azure.proton.transport.ws.impl.Utils"));
runtimeInitializedClass
.produce(new RuntimeInitializedClassBuildItem(DigestProxyChallengeProcessorImpl.class.getName()));
}

@BuildStep
NativeImageProxyDefinitionBuildItem nativeImageProxyDefinitions() {
return new NativeImageProxyDefinitionBuildItem(SecretClientImpl.SecretClientService.class.getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-extensions-jvm</artifactId>
<artifactId>camel-quarkus-extensions</artifactId>
<version>3.13.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

<properties>
<camel.quarkus.jvmSince>2.10.0</camel.quarkus.jvmSince>
<camel.quarkus.nativeSince>3.13.0</camel.quarkus.nativeSince>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ name: "Camel Azure Key Vault"
description: "Manage secrets and keys in Azure Key Vault Service"
metadata:
icon-url: "https://raw.githubusercontent.com/apache/camel-website/main/antora-ui-camel/src/img/logo-d.svg"
unlisted: true
guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/azure-key-vault.html"
categories:
- "integration"
status:
- "preview"
- "stable"
1 change: 1 addition & 0 deletions extensions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<module>aws2-sts</module>
<module>aws2-translate</module>
<module>azure-eventhubs</module>
<module>azure-key-vault</module>
<module>azure-storage-blob</module>
<module>azure-storage-queue</module>
<module>base64</module>
Expand Down
5 changes: 4 additions & 1 deletion integration-test-groups/azure/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-po
* View the https://docs.microsoft.com/en-us/azure/storage/common/storage-account-keys-manage?tabs=azure-portal#view-account-access-keys[account keys] and set the following environment variables:
* An https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-create[Azure Event Hub]
* An https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-get-connection-string[Event Hubs connection string]
* A https://learn.microsoft.com/en-us/azure/key-vault/general/overview[Key Vault] configured in your Azure account

To create all of the above, you can use `azure-resources.sh` script as follows. Ensure that you have installed the https://docs.microsoft.com/en-us/cli/azure/[Azure CLI] beforehand:

Expand All @@ -36,10 +37,12 @@ Here are the environment variables you need to set:
export AZURE_STORAGE_ACCOUNT_NAME=<your-azure-storage-account-name>
export AZURE_STORAGE_ACCOUNT_KEY=<your-azure-storage-account-key>
# optional to test alternate authentication methods
export AZURE_CLIENT_ID=<your-azure-app-client-id>
export AZURE_CLIENT_SECRET=<your-azure-app-client-secret>
export AZURE_TENANT_ID=<your-azure-app-tenant-id>
export AZURE_VAULT_NAME=<your-azure-key-vault-name>
# optional to test alternate authentication methods
export AZURE_CLIENT_CERTIFICATE_PATH=<your-azure-app-certificate-pem-file>
# the container has to exist before you run the test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,13 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-build-parent-it</artifactId>
<version>3.13.0-SNAPSHOT</version>
<relativePath>../../poms/build-parent-it/pom.xml</relativePath>
<relativePath>../../../poms/build-parent-it/pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-integration-test-azure-key-vault</artifactId>
<name>Camel Quarkus :: Integration Tests :: Azure Key Vault</name>
<description>Integration tests for Camel Quarkus Azure Key Vault extension</description>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>${quarkus.platform.group-id}</groupId>
<artifactId>${quarkus.platform.artifact-id}</artifactId>
<version>${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-bom-test</artifactId>
<version>${camel-quarkus.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
Expand Down Expand Up @@ -82,6 +63,33 @@
</dependencies>

<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.native.enabled>true</quarkus.native.enabled>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>virtualDependencies</id>
<activation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
## limitations under the License.
## ---------------------------------------------------------------------------
#
camel.vault.azure.tenantId = ${AZURE_TENANT_ID}
camel.vault.azure.clientId = ${AZURE_CLIENT_ID}
camel.vault.azure.clientSecret = ${AZURE_CLIENT_SECRET}
camel.vault.azure.tenantId = ${AZURE_TENANT_ID:placeholderTenantId}
camel.vault.azure.clientId = ${AZURE_CLIENT_ID:placeholderClientId}
camel.vault.azure.clientSecret = ${AZURE_CLIENT_SECRET:placeholderClientSecret}
camel.vault.azure.vaultName = ${AZURE_VAULT_NAME:cq-vault-testing}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* 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.quarkus.component.azure.key.vault.it;

import io.quarkus.test.junit.QuarkusIntegrationTest;
import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;

// Azure Key Vault is not supported by Azurite https://github.com/Azure/Azurite/issues/619
@EnabledIfEnvironmentVariable(named = "AZURE_TENANT_ID", matches = ".+")
@EnabledIfEnvironmentVariable(named = "AZURE_CLIENT_ID", matches = ".+")
@EnabledIfEnvironmentVariable(named = "AZURE_CLIENT_SECRET", matches = ".+")
@EnabledIfEnvironmentVariable(named = "AZURE_VAULT_NAME", matches = ".+")
@QuarkusIntegrationTest
class AzureKeyVaultIT extends AzureKeyVaultTest {

}
Loading

0 comments on commit 591b0aa

Please sign in to comment.