You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by "oscerd (via GitHub)" <gi...@apache.org> on 2026/08/24 08:34:33 UTC

[PR] CAMEL-23305: camel-spiffe - new component for SPIFFE workload identity (X.509-SVID / JWT-SVID) [camel]

oscerd opened a new pull request, #25621:
URL: https://github.com/apache/camel/pull/25621

   ## What
   
   New **`camel-spiffe`** producer component (CAMEL-23305) integrating with the SPIFFE Workload API via `io.spiffe:java-spiffe-core` (Apache-2.0, on Maven Central) to provide cryptographic workload identity to Camel routes.
   
   ### Operations
   - `fetchX509Svid` — fetch the default X.509-SVID (mTLS cert chain + private key + SPIFFE ID). Body = `X509Svid`.
   - `fetchJwtSvid` — fetch a JWT-SVID for the configured / `CamelSpiffeAudience`-headered audience(s). Body = JWT token; `CamelSpiffeSpiffeId` / `CamelSpiffeExpiry` headers.
   - `validateJwtSvid` — validate a JWT-SVID (from the `CamelSpiffeToken` header or body) against an audience. Body = validated `JwtSvid`.
   
   The Workload API endpoint comes from the `spiffeSocketPath` option or the standard `SPIFFE_ENDPOINT_SOCKET` env var; an already-configured `WorkloadApiClient` can also be injected (`workloadApiClient` option) for advanced/testing use.
   
   ### Scope note
   This is the **first increment** of CAMEL-23305. The issue also proposes an `SSLContextParameters` implementation backed by the SPIFFE Workload API (with rotation) for zero-trust mTLS across TLS-capable components — left as a **follow-up**, as it's a deeper, design-heavy integration.
   
   ## Testing
   - `SpiffeProducerTest` (5 tests, Mockito + AssertJ, mocked `WorkloadApiClient`): all three operations, audience-from-header, and the missing-audience failure path.
   - Full-reactor `mvn clean install -DskipTests` passes; catalog / endpoint-DSL / component-DSL / BOM / docs all regenerated and committed.
   
   ## Dependency
   `io.spiffe:java-spiffe-core:0.8.17` — Apache-2.0, published to Maven Central, actively maintained.
   
   _Claude Code on behalf of oscerd_
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-23305: camel-spiffe - new component for SPIFFE workload identity (X.509-SVID / JWT-SVID) [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #25621:
URL: https://github.com/apache/camel/pull/25621#issuecomment-5393232647

   :star2: Thank you for your contribution to the Apache Camel project! :star2:
     :robot: CI automation will test this PR automatically.
   
     :camel: Apache Camel Committers, please review the following items:
   
     * First-time contributors **require MANUAL approval** for the GitHub Actions to run
     * You can use the command `/component-test (camel-)component-name1 (camel-)component-name2..` to request a test from the test bot although they are normally detected and executed by CI.
     * You can label PRs using `skip-tests` and `test-dependents` to fine-tune the checks executed by this PR.
     * Build and test logs are available in the summary page. **Only** [Apache Camel committers](https://camel.apache.org/community/team/#committers) have access to the summary.
     
     :warning: Be careful when sharing logs. Review their contents before sharing them publicly.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-23305: camel-spiffe - new component for SPIFFE workload identity (X.509-SVID / JWT-SVID) [camel]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #25621:
URL: https://github.com/apache/camel/pull/25621#issuecomment-5393675593

   <!-- ci-tested-modules -->
   :test_tube: **CI tested the following changed modules:**
   
   - `bom/camel-bom`
   - `catalog/camel-allcomponents`
   - `catalog/camel-catalog`
   - `components`
   - `components/camel-spiffe`
   - `core/camel-main`
   - `docs`
   - `dsl/camel-componentdsl`
   - `dsl/camel-endpointdsl`
   - `dsl/camel-kamelet-main`
   - `parent`
   
   > :information_source: Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the `test-dependents` label to force testing all dependents.
   
   :white_check_mark: **POM dependency changes: targeted tests included**
   
   Changed properties: java-spiffe-version
   
   <details><summary>Modules affected by dependency changes (1)</summary>
   
   - `:camel-spiffe`
   
   </details>
   
   ---
   
   <details><summary>:microscope: Scalpel shadow comparison — Scalpel: 70 tested, 23 compile-only — current: 63 all tested</summary>
   
   [Maveniverse Scalpel](https://github.com/maveniverse/scalpel) detected **93 affected modules** (current approach: 63).
   
   <details><summary>:warning: Modules only in Scalpel (30)</summary>
   
   - `apache-camel`
   - `camel-allcomponents`
   - `camel-bom`
   - `camel-catalog`
   - `camel-catalog-console`
   - `camel-catalog-lucene`
   - `camel-catalog-maven`
   - `camel-catalog-suggest`
   - `camel-componentdsl`
   - `camel-csimple-maven-plugin`
   - `camel-endpointdsl`
   - `camel-endpointdsl-support`
   - `camel-itest`
   - `camel-jbang-core`
   - `camel-jbang-it`
   - `camel-jbang-main`
   - `camel-jbang-plugin-edit`
   - `camel-jbang-plugin-generate`
   - `camel-jbang-plugin-kubernetes`
   - `camel-jbang-plugin-test`
   - `camel-kamelet-main`
   - `camel-launcher`
   - `camel-report-maven-plugin`
   - `camel-route-parser`
   - `camel-yaml-dsl`
   - `camel-yaml-dsl-deserializers`
   - `camel-yaml-dsl-maven-plugin`
   - `coverage`
   - `docs`
   - `dummy-component`
   
   </details>
   
   Changed properties: java-spiffe-version
   
   Changed managed dependencies: org.apache.camel:camel-spiffe
   
   **Skip-tests mode would test 70 modules** (9 direct + 61 downstream), **skip tests for 23** (generated code, meta-modules)
   
   <details><summary>Modules Scalpel would test (70)</summary>
   
   - `camel-a2a`
   - `camel-allcomponents`
   - `camel-as2`
   - `camel-bom`
   - `camel-catalog`
   - `camel-clickup`
   - `camel-componentdsl`
   - `camel-consul`
   - `camel-core-all`
   - `camel-csv`
   - `camel-endpointdsl`
   - `camel-fhir`
   - `camel-groovy`
   - `camel-hazelcast`
   - `camel-hl7`
   - `camel-ibm-watsonx-ai`
   - `camel-iso8583`
   - `camel-java-joor-dsl`
   - `camel-jbang-mcp`
   - `camel-jbang-plugin-mcp`
   - `camel-jbang-plugin-route-parser`
   - `camel-jbang-plugin-tui`
   - `camel-jbang-plugin-validate`
   - `camel-jetty`
   - `camel-jsonpath`
   - `camel-kamelet`
   - `camel-kamelet-main`
   - `camel-kamelet-main-support`
   - `camel-knative-http`
   - `camel-launcher-container`
   - `camel-mail`
   - `camel-mail-microsoft-oauth`
   - `camel-main`
   - `camel-maven-plugin`
   - `camel-mcp-server`
   - `camel-micrometer-prometheus`
   - `camel-microprofile-health`
   - `camel-netty`
   - `camel-netty-http`
   - `camel-oauth`
   - `camel-observability-services`
   - `camel-once`
   - `camel-openapi-validator`
   - `camel-platform-http-main`
   - `camel-platform-http-vertx`
   - `camel-plc4x`
   - `camel-pubnub`
   - `camel-quickfix`
   - `camel-rest-openapi`
   - `camel-restdsl-openapi-plugin`
   - `camel-salesforce`
   - `camel-salesforce-codegen`
   - `camel-salesforce-maven-plugin`
   - `camel-spiffe`
   - `camel-spring-main`
   - `camel-syslog`
   - `camel-telegram`
   - `camel-test-main-junit5`
   - `camel-test-main-junit6`
   - `camel-vertx-websocket`
   - `camel-webhook`
   - `camel-whatsapp`
   - `camel-xml-io-dsl`
   - `camel-xml-jaxb-dsl`
   - `camel-xml-jaxb-dsl-test-definition`
   - `camel-xml-jaxb-dsl-test-spring`
   - `camel-yaml-dsl-validator`
   - `camel-yaml-dsl-validator-maven-plugin`
   - `camel-zookeeper`
   - `docs`
   
   </details>
   
   <details><summary>Modules with tests skipped (23)</summary>
   
   - `apache-camel`
   - `camel-catalog-console`
   - `camel-catalog-lucene`
   - `camel-catalog-maven`
   - `camel-catalog-suggest`
   - `camel-csimple-maven-plugin`
   - `camel-endpointdsl-support`
   - `camel-itest`
   - `camel-jbang-core`
   - `camel-jbang-it`
   - `camel-jbang-main`
   - `camel-jbang-plugin-edit`
   - `camel-jbang-plugin-generate`
   - `camel-jbang-plugin-kubernetes`
   - `camel-jbang-plugin-test`
   - `camel-launcher`
   - `camel-report-maven-plugin`
   - `camel-route-parser`
   - `camel-yaml-dsl`
   - `camel-yaml-dsl-deserializers`
   - `camel-yaml-dsl-maven-plugin`
   - `coverage`
   - `dummy-component`
   
   </details>
   
   > :information_source: Shadow mode — Scalpel observes but does not affect test execution. [Learn more](https://github.com/maveniverse/scalpel)
   
   </details>
   
   :warning: **Some tests are disabled on GitHub Actions** (`@DisabledIfSystemProperty(named = "ci.env.name")`) and require manual verification:
   
   - `components`: 103 test(s) disabled on GitHub Actions
   
   <details><summary>Build reactor — dependencies compiled but only changed modules were tested (95 modules)</summary>
   
   - Camel :: AI :: A2A
   - Camel :: AI :: MCP Server
   - Camel :: AS2 :: Component
   - Camel :: All Components Sync point
   - Camel :: All Core Sync point
   - Camel :: Assembly
   - Camel :: BOM
   - Camel :: CSV
   - Camel :: Catalog :: CSimple Maven Plugin (deprecated)
   - Camel :: Catalog :: Camel Catalog
   - Camel :: Catalog :: Camel Report Maven Plugin
   - Camel :: Catalog :: Camel Route Parser
   - Camel :: Catalog :: Console
   - Camel :: Catalog :: Dummy Component
   - Camel :: Catalog :: Lucene (deprecated)
   - Camel :: Catalog :: Maven
   - Camel :: Catalog :: Suggest
   - Camel :: ClickUp
   - Camel :: Component DSL
   - Camel :: Components
   - Camel :: Consul
   - Camel :: Coverage
   - Camel :: Docs
   - Camel :: Endpoint DSL
   - Camel :: Endpoint DSL :: Support
   - Camel :: FHIR
   - Camel :: Groovy
   - Camel :: HL7
   - Camel :: HazelCast
   - Camel :: IBM :: watsonx.ai
   - Camel :: ISO-8583
   - Camel :: Integration Tests
   - Camel :: JBang :: Core
   - Camel :: JBang :: Integration tests
   - Camel :: JBang :: MCP
   - Camel :: JBang :: Main
   - Camel :: JBang :: Plugin :: Edit
   - Camel :: JBang :: Plugin :: Generate
   - Camel :: JBang :: Plugin :: Kubernetes
   - Camel :: JBang :: Plugin :: MCP
   - Camel :: JBang :: Plugin :: Route Parser
   - Camel :: JBang :: Plugin :: TUI
   - Camel :: JBang :: Plugin :: Testing
   - Camel :: JBang :: Plugin :: Validate
   - Camel :: JSon Path
   - Camel :: Java DSL with jOOR
   - Camel :: Jetty
   - Camel :: Kamelet
   - Camel :: Kamelet Main
   - Camel :: Kamelet Main :: Support
   - Camel :: Knative HTTP
   - Camel :: Launcher
   - Camel :: Launcher :: Container
   - Camel :: Mail
   - Camel :: Mail :: Microsoft OAuth
   - Camel :: Main
   - Camel :: Maven Plugins :: Camel Maven Plugin
   - Camel :: Maven Plugins :: OpenApi REST DSL Generator
   - Camel :: MicroProfile :: Health
   - Camel :: Micrometer :: Prometheus
   - Camel :: Netty
   - Camel :: Netty HTTP
   - Camel :: OAuth
   - Camel :: Observability Services
   - Camel :: Once
   - Camel :: OpenAPI :: Validator
   - Camel :: PLC4X
   - Camel :: Parent
   - Camel :: Platform HTTP :: Main
   - Camel :: Platform HTTP :: Vert.x
   - Camel :: PubNub
   - Camel :: QuickFIX/J
   - Camel :: REST OpenApi
   - Camel :: SPIFFE
   - Camel :: Salesforce
   - Camel :: Salesforce :: CodeGen
   - Camel :: Salesforce :: Maven Plugin
   - Camel :: Spring Main
   - Camel :: Syslog
   - Camel :: Telegram
   - Camel :: Test :: Main :: JUnit5
   - Camel :: Test :: Main :: JUnit6
   - Camel :: Vert.x :: WebSocket
   - Camel :: Webhook
   - Camel :: Whatsapp
   - Camel :: XML DSL Jaxb :: Test :: Definition
   - Camel :: XML DSL Jaxb :: Test :: Spring
   - Camel :: XML DSL with camel-xml-io
   - Camel :: XML DSL with camel-xml-jaxb
   - Camel :: YAML DSL
   - Camel :: YAML DSL :: Deserializers
   - Camel :: YAML DSL :: Maven Plugins
   - Camel :: YAML DSL :: Validator
   - Camel :: YAML DSL :: Validator Maven Plugin
   - Camel :: Zookeeper
   
   </details>
   
   ---
   :gear: [View full build and test results](https://github.com/apache/camel/actions/runs/32707005992)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-23305: camel-spiffe - new component for SPIFFE workload identity (X.509-SVID / JWT-SVID) [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #25621:
URL: https://github.com/apache/camel/pull/25621#discussion_r3849747001


##########
components/camel-spiffe/src/main/docs/spiffe-component.adoc:
##########
@@ -0,0 +1,80 @@
+= SPIFFE Component
+:doctitle: SPIFFE
+:shortname: spiffe
+:artifactid: camel-spiffe
+:description: Fetch and validate SPIFFE workload identity (X.509-SVID and JWT-SVID) from the SPIFFE Workload API.
+:since: 4.23
+:supportlevel: Preview
+:tabs-sync-option:
+:component-header: Only producer is supported
+
+*Since Camel {since}*
+
+*{component-header}*
+
+The SPIFFE component integrates with the https://spiffe.io/[SPIFFE] (Secure Production Identity Framework
+For Everyone) Workload API to provide cryptographic workload identity to Camel routes. It talks to a local
+SPIFFE Workload API endpoint — for example the one exposed by a https://spiffe.io/docs/latest/spire-about/[SPIRE]
+agent — to fetch and validate SVIDs (SPIFFE Verifiable Identity Documents):
+
+* *X.509-SVID*: an X.509 certificate whose SPIFFE ID is encoded as a URI SAN, used for mutual TLS.
+* *JWT-SVID*: a JWT whose subject is the SPIFFE ID, used as a bearer token for workload-to-workload authentication.
+
+Maven users will need to add the following dependency to their `pom.xml`.
+
+[source,xml]
+------------------------------------------------------------
+<dependency>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-spiffe</artifactId>
+    <version>x.x.x</version>
+    <!-- use the same version as your Camel core version -->
+</dependency>
+------------------------------------------------------------
+
+== URI Format
+
+------------------------------------------------------------
+spiffe:label[?options]
+------------------------------------------------------------
+
+Where `label` is a logical name for the endpoint.
+
+// component options: START
+include::partial$component-configure-options.adoc[]
+include::partial$component-endpoint-options.adoc[]
+include::partial$component-endpoint-headers.adoc[]
+// component options: END
+
+== Workload API endpoint
+
+The address of the SPIFFE Workload API is taken from the `spiffeSocketPath` option, or, when that is not set, from
+the standard `SPIFFE_ENDPOINT_SOCKET` environment variable — for example `unix:///tmp/spire-agent/public/api.sock`.
+For advanced scenarios an already-configured `io.spiffe.workloadapi.WorkloadApiClient` can be supplied through the
+`workloadApiClient` option; in that case the component neither creates nor closes the client.
+
+== Operations
+
+The component supports the following producer operations:
+
+* `fetchX509Svid` — fetches the default X.509-SVID from the Workload API. The message body is set to the
+`io.spiffe.svid.x509svid.X509Svid` (certificate chain, private key and SPIFFE ID) and the `CamelSpiffeSpiffeId`
+header to its SPIFFE ID.
+* `fetchJwtSvid` — fetches a JWT-SVID for the configured `audience` (or the `CamelSpiffeAudience` header). The

Review Comment:
   Good call — added in 2b55ef7. There is now a NOTE in the Operations section warning that `fetchX509Svid` (private key in the `X509Svid`) and `fetchJwtSvid` (bearer token) place sensitive material on the message body, and advising against logging/tracing it via the `log`/`trace` components or message-history EIPs. Leaving the thread for you to resolve.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-23305: camel-spiffe - new component for SPIFFE workload identity (X.509-SVID / JWT-SVID) [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on PR #25621:
URL: https://github.com/apache/camel/pull/25621#issuecomment-5394451841

   Thanks for the review @gnodet — all four observations are addressed in f7ff00a:
   
   1. **`java-spiffe-version` placement** — moved to its alphabetical slot among the other `java-*` properties (between `java-grok-version` and `java-util-version`) in `parent/pom.xml`, out of the Spring block.
   2. **FQCN `@Metadata`** — now imported (`org.apache.camel.spi.Metadata`) and used as the simple name in `SpiffeEndpoint`.
   3. **`validateJwtSvid` body-fallback coverage** — added `validateJwtSvidTokenFromBody`, which puts the token on the message body with no `CamelSpiffeToken` header and asserts the validated SVID.
   4. **Multi-audience / comma-parsing coverage** — added `fetchJwtSvidMultipleAudiences` using `"aud1, aud2, aud3"` (with spaces) to exercise both the split/trim in `resolveAudiences` and the `audiences.length > 1` varargs branch in `fetchJwtSvid`.
   
   Module tests are green (7/7) and a full-reactor `install -DskipTests` produced no catalog/DSL drift, so the import swap and property move are metadata-neutral.
   
   On the PR metadata: milestone set to `4.23.0` and the `core` label removed (the core-side changes are only generated catalog/DSL/main artifacts). The deferred `SSLContextParameters`-backed Workload-API mTLS remains tracked on CAMEL-23305 for a later increment.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-23305: camel-spiffe - new component for SPIFFE workload identity (X.509-SVID / JWT-SVID) [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd merged PR #25621:
URL: https://github.com/apache/camel/pull/25621


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-23305: camel-spiffe - new component for SPIFFE workload identity (X.509-SVID / JWT-SVID) [camel]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #25621:
URL: https://github.com/apache/camel/pull/25621#discussion_r3853328772


##########
components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeProducer.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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.component.spiffe;
+
+import java.util.Arrays;
+
+import io.spiffe.svid.jwtsvid.JwtSvid;
+import io.spiffe.svid.x509svid.X509Svid;
+import io.spiffe.workloadapi.WorkloadApiClient;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+
+public class SpiffeProducer extends DefaultProducer {
+
+    public SpiffeProducer(final SpiffeEndpoint endpoint) {
+        super(endpoint);
+    }
+
+    @Override
+    public SpiffeEndpoint getEndpoint() {
+        return (SpiffeEndpoint) super.getEndpoint();
+    }
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        final WorkloadApiClient client = getEndpoint().getWorkloadApiClient();
+        switch (determineOperation(exchange)) {
+            case fetchX509Svid -> fetchX509Svid(client, exchange);
+            case fetchJwtSvid -> fetchJwtSvid(client, exchange);
+            case validateJwtSvid -> validateJwtSvid(client, exchange);
+            default -> throw new IllegalArgumentException("Unsupported operation");
+        }
+    }
+
+    private void fetchX509Svid(WorkloadApiClient client, Exchange exchange) throws Exception {
+        X509Svid svid = client.fetchX509Context().getDefaultSvid();
+        Message message = getMessageForResponse(exchange);
+        message.setBody(svid);
+        message.setHeader(SpiffeConstants.SPIFFE_ID, svid.getSpiffeId().toString());
+    }
+
+    private void fetchJwtSvid(WorkloadApiClient client, Exchange exchange) throws Exception {
+        String[] audiences = resolveAudiences(exchange);
+        JwtSvid svid = audiences.length > 1
+                ? client.fetchJwtSvid(audiences[0], Arrays.copyOfRange(audiences, 1, audiences.length))
+                : client.fetchJwtSvid(audiences[0]);
+        Message message = getMessageForResponse(exchange);
+        message.setBody(svid.getToken());
+        message.setHeader(SpiffeConstants.SPIFFE_ID, svid.getSpiffeId().toString());
+        message.setHeader(SpiffeConstants.EXPIRY, svid.getExpiry());
+    }
+
+    private void validateJwtSvid(WorkloadApiClient client, Exchange exchange) throws Exception {
+        String token = exchange.getIn().getHeader(SpiffeConstants.TOKEN, String.class);
+        if (ObjectHelper.isEmpty(token)) {
+            token = exchange.getIn().getBody(String.class);
+        }
+        if (ObjectHelper.isEmpty(token)) {
+            throw new IllegalArgumentException(
+                    "A JWT-SVID token is required for validateJwtSvid (set the CamelSpiffeToken header or the body)");
+        }
+        String[] audiences = resolveAudiences(exchange);
+        JwtSvid svid = client.validateJwtSvid(token, audiences[0]);
+        Message message = getMessageForResponse(exchange);
+        message.setBody(svid);

Review Comment:
   **Observation (non-blocking):** `validateJwtSvid` silently uses only `audiences[0]` when the user provides multiple comma-separated audiences. This is correct for the SPIFFE API (which validates one audience at a time), but it's inconsistent with `fetchJwtSvid` which passes all audiences through.
   
   A user who sets `audience=aud1,aud2` may not realize only `aud1` is used for validation. Consider either:
   - Logging a warning when extra audiences are ignored, or
   - Documenting this single-audience behavior explicitly in the `@UriParam` description



##########
components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeConfiguration.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.component.spiffe;
+
+import io.spiffe.workloadapi.WorkloadApiClient;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+
+@UriParams
+public class SpiffeConfiguration implements Cloneable {
+
+    @UriParam(defaultValue = "fetchX509Svid")
+    private SpiffeOperation operation = SpiffeOperation.fetchX509Svid;
+
+    @UriParam(label = "security")
+    private String spiffeSocketPath;
+
+    @UriParam
+    private String audience;
+
+    @UriParam(label = "advanced", description = "An existing WorkloadApiClient to use. When set, the component does not"
+                                                + " create or close its own client and spiffeSocketPath is ignored.")
+    private WorkloadApiClient workloadApiClient;
+
+    /**
+     * The operation to perform on the SPIFFE Workload API.
+     */

Review Comment:
   **Minor convention suggestion (non-blocking):** The `workloadApiClient` option is not marked with `autowired = true` on its `@UriParam`. Many Camel components mark their injectable client objects as autowired (e.g., AWS components with SDK clients), which enables automatic lookup from the Camel registry without needing the `#beanRef` syntax.
   
   Consider adding `autowired = true` to the annotation.



##########
components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeProducer.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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.component.spiffe;
+
+import java.util.Arrays;
+
+import io.spiffe.svid.jwtsvid.JwtSvid;
+import io.spiffe.svid.x509svid.X509Svid;
+import io.spiffe.workloadapi.WorkloadApiClient;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+
+public class SpiffeProducer extends DefaultProducer {
+
+    public SpiffeProducer(final SpiffeEndpoint endpoint) {
+        super(endpoint);
+    }
+
+    @Override
+    public SpiffeEndpoint getEndpoint() {
+        return (SpiffeEndpoint) super.getEndpoint();
+    }
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        final WorkloadApiClient client = getEndpoint().getWorkloadApiClient();
+        switch (determineOperation(exchange)) {
+            case fetchX509Svid -> fetchX509Svid(client, exchange);
+            case fetchJwtSvid -> fetchJwtSvid(client, exchange);
+            case validateJwtSvid -> validateJwtSvid(client, exchange);
+            default -> throw new IllegalArgumentException("Unsupported operation");
+        }
+    }
+
+    private void fetchX509Svid(WorkloadApiClient client, Exchange exchange) throws Exception {
+        X509Svid svid = client.fetchX509Context().getDefaultSvid();
+        Message message = getMessageForResponse(exchange);
+        message.setBody(svid);
+        message.setHeader(SpiffeConstants.SPIFFE_ID, svid.getSpiffeId().toString());
+    }
+
+    private void fetchJwtSvid(WorkloadApiClient client, Exchange exchange) throws Exception {
+        String[] audiences = resolveAudiences(exchange);
+        JwtSvid svid = audiences.length > 1
+                ? client.fetchJwtSvid(audiences[0], Arrays.copyOfRange(audiences, 1, audiences.length))
+                : client.fetchJwtSvid(audiences[0]);
+        Message message = getMessageForResponse(exchange);
+        message.setBody(svid.getToken());
+        message.setHeader(SpiffeConstants.SPIFFE_ID, svid.getSpiffeId().toString());
+        message.setHeader(SpiffeConstants.EXPIRY, svid.getExpiry());
+    }
+
+    private void validateJwtSvid(WorkloadApiClient client, Exchange exchange) throws Exception {
+        String token = exchange.getIn().getHeader(SpiffeConstants.TOKEN, String.class);
+        if (ObjectHelper.isEmpty(token)) {
+            token = exchange.getIn().getBody(String.class);
+        }
+        if (ObjectHelper.isEmpty(token)) {
+            throw new IllegalArgumentException(
+                    "A JWT-SVID token is required for validateJwtSvid (set the CamelSpiffeToken header or the body)");
+        }
+        String[] audiences = resolveAudiences(exchange);
+        JwtSvid svid = client.validateJwtSvid(token, audiences[0]);
+        Message message = getMessageForResponse(exchange);
+        message.setBody(svid);
+        message.setHeader(SpiffeConstants.SPIFFE_ID, svid.getSpiffeId().toString());
+    }
+
+    private SpiffeOperation determineOperation(Exchange exchange) {
+        SpiffeOperation operation
+                = exchange.getIn().getHeader(SpiffeConstants.OPERATION, SpiffeOperation.class);
+        return operation != null ? operation : getEndpoint().getConfiguration().getOperation();
+    }
+
+    private String[] resolveAudiences(Exchange exchange) {
+        String audience = exchange.getIn().getHeader(SpiffeConstants.AUDIENCE, String.class);
+        if (ObjectHelper.isEmpty(audience)) {
+            audience = getEndpoint().getConfiguration().getAudience();
+        }
+        if (ObjectHelper.isEmpty(audience)) {
+            throw new IllegalArgumentException(
+                    "At least one audience is required (set the audience option or the CamelSpiffeAudience header)");
+        }

Review Comment:
   **Minor robustness suggestion (non-blocking):** `resolveAudiences` splits on comma and trims, but doesn't filter out empty/blank strings. An input like `"aud1,,aud2"` would produce an empty-string audience entry that would be passed to the SPIFFE API.
   
   Consider adding a filter:
   ```java
   return Arrays.stream(audience.split(","))
       .map(String::trim)
       .filter(s -> !s.isEmpty())
       .toArray(String[]::new);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-23305: camel-spiffe - new component for SPIFFE workload identity (X.509-SVID / JWT-SVID) [camel]

Posted by "oscerd (via GitHub)" <gi...@apache.org>.
oscerd commented on code in PR #25621:
URL: https://github.com/apache/camel/pull/25621#discussion_r3870811330


##########
components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeProducer.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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.component.spiffe;
+
+import java.util.Arrays;
+
+import io.spiffe.svid.jwtsvid.JwtSvid;
+import io.spiffe.svid.x509svid.X509Svid;
+import io.spiffe.workloadapi.WorkloadApiClient;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+
+public class SpiffeProducer extends DefaultProducer {
+
+    public SpiffeProducer(final SpiffeEndpoint endpoint) {
+        super(endpoint);
+    }
+
+    @Override
+    public SpiffeEndpoint getEndpoint() {
+        return (SpiffeEndpoint) super.getEndpoint();
+    }
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        final WorkloadApiClient client = getEndpoint().getWorkloadApiClient();
+        switch (determineOperation(exchange)) {
+            case fetchX509Svid -> fetchX509Svid(client, exchange);
+            case fetchJwtSvid -> fetchJwtSvid(client, exchange);
+            case validateJwtSvid -> validateJwtSvid(client, exchange);
+            default -> throw new IllegalArgumentException("Unsupported operation");
+        }
+    }
+
+    private void fetchX509Svid(WorkloadApiClient client, Exchange exchange) throws Exception {
+        X509Svid svid = client.fetchX509Context().getDefaultSvid();
+        Message message = getMessageForResponse(exchange);
+        message.setBody(svid);
+        message.setHeader(SpiffeConstants.SPIFFE_ID, svid.getSpiffeId().toString());
+    }
+
+    private void fetchJwtSvid(WorkloadApiClient client, Exchange exchange) throws Exception {
+        String[] audiences = resolveAudiences(exchange);
+        JwtSvid svid = audiences.length > 1
+                ? client.fetchJwtSvid(audiences[0], Arrays.copyOfRange(audiences, 1, audiences.length))
+                : client.fetchJwtSvid(audiences[0]);
+        Message message = getMessageForResponse(exchange);
+        message.setBody(svid.getToken());
+        message.setHeader(SpiffeConstants.SPIFFE_ID, svid.getSpiffeId().toString());
+        message.setHeader(SpiffeConstants.EXPIRY, svid.getExpiry());
+    }
+
+    private void validateJwtSvid(WorkloadApiClient client, Exchange exchange) throws Exception {
+        String token = exchange.getIn().getHeader(SpiffeConstants.TOKEN, String.class);
+        if (ObjectHelper.isEmpty(token)) {
+            token = exchange.getIn().getBody(String.class);
+        }
+        if (ObjectHelper.isEmpty(token)) {
+            throw new IllegalArgumentException(
+                    "A JWT-SVID token is required for validateJwtSvid (set the CamelSpiffeToken header or the body)");
+        }
+        String[] audiences = resolveAudiences(exchange);
+        JwtSvid svid = client.validateJwtSvid(token, audiences[0]);
+        Message message = getMessageForResponse(exchange);
+        message.setBody(svid);

Review Comment:
   Documented in 7bb3361. The `audience` option description now states that validateJwtSvid validates against a single audience — when several comma-separated audiences are given only the first is used for validation, while fetchJwtSvid requests all of them. I chose documentation over a runtime warning to avoid per-message log noise.



##########
components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeProducer.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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.component.spiffe;
+
+import java.util.Arrays;
+
+import io.spiffe.svid.jwtsvid.JwtSvid;
+import io.spiffe.svid.x509svid.X509Svid;
+import io.spiffe.workloadapi.WorkloadApiClient;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+
+public class SpiffeProducer extends DefaultProducer {
+
+    public SpiffeProducer(final SpiffeEndpoint endpoint) {
+        super(endpoint);
+    }
+
+    @Override
+    public SpiffeEndpoint getEndpoint() {
+        return (SpiffeEndpoint) super.getEndpoint();
+    }
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        final WorkloadApiClient client = getEndpoint().getWorkloadApiClient();
+        switch (determineOperation(exchange)) {
+            case fetchX509Svid -> fetchX509Svid(client, exchange);
+            case fetchJwtSvid -> fetchJwtSvid(client, exchange);
+            case validateJwtSvid -> validateJwtSvid(client, exchange);
+            default -> throw new IllegalArgumentException("Unsupported operation");
+        }
+    }
+
+    private void fetchX509Svid(WorkloadApiClient client, Exchange exchange) throws Exception {
+        X509Svid svid = client.fetchX509Context().getDefaultSvid();
+        Message message = getMessageForResponse(exchange);
+        message.setBody(svid);
+        message.setHeader(SpiffeConstants.SPIFFE_ID, svid.getSpiffeId().toString());
+    }
+
+    private void fetchJwtSvid(WorkloadApiClient client, Exchange exchange) throws Exception {
+        String[] audiences = resolveAudiences(exchange);
+        JwtSvid svid = audiences.length > 1
+                ? client.fetchJwtSvid(audiences[0], Arrays.copyOfRange(audiences, 1, audiences.length))
+                : client.fetchJwtSvid(audiences[0]);
+        Message message = getMessageForResponse(exchange);
+        message.setBody(svid.getToken());
+        message.setHeader(SpiffeConstants.SPIFFE_ID, svid.getSpiffeId().toString());
+        message.setHeader(SpiffeConstants.EXPIRY, svid.getExpiry());
+    }
+
+    private void validateJwtSvid(WorkloadApiClient client, Exchange exchange) throws Exception {
+        String token = exchange.getIn().getHeader(SpiffeConstants.TOKEN, String.class);
+        if (ObjectHelper.isEmpty(token)) {
+            token = exchange.getIn().getBody(String.class);
+        }
+        if (ObjectHelper.isEmpty(token)) {
+            throw new IllegalArgumentException(
+                    "A JWT-SVID token is required for validateJwtSvid (set the CamelSpiffeToken header or the body)");
+        }
+        String[] audiences = resolveAudiences(exchange);
+        JwtSvid svid = client.validateJwtSvid(token, audiences[0]);
+        Message message = getMessageForResponse(exchange);
+        message.setBody(svid);
+        message.setHeader(SpiffeConstants.SPIFFE_ID, svid.getSpiffeId().toString());
+    }
+
+    private SpiffeOperation determineOperation(Exchange exchange) {
+        SpiffeOperation operation
+                = exchange.getIn().getHeader(SpiffeConstants.OPERATION, SpiffeOperation.class);
+        return operation != null ? operation : getEndpoint().getConfiguration().getOperation();
+    }
+
+    private String[] resolveAudiences(Exchange exchange) {
+        String audience = exchange.getIn().getHeader(SpiffeConstants.AUDIENCE, String.class);
+        if (ObjectHelper.isEmpty(audience)) {
+            audience = getEndpoint().getConfiguration().getAudience();
+        }
+        if (ObjectHelper.isEmpty(audience)) {
+            throw new IllegalArgumentException(
+                    "At least one audience is required (set the audience option or the CamelSpiffeAudience header)");
+        }

Review Comment:
   Applied in 7bb3361. `resolveAudiences` now trims and filters out blank entries (`Arrays.stream(...).map(String::trim).filter(s -> !s.isEmpty())`) and throws if nothing non-blank remains, so an input like `aud1,,aud2` no longer yields an empty audience. I also extended the multi-audience test to include a blank element (`aud1, , aud2, aud3`).



##########
components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeConfiguration.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.component.spiffe;
+
+import io.spiffe.workloadapi.WorkloadApiClient;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriParams;
+
+@UriParams
+public class SpiffeConfiguration implements Cloneable {
+
+    @UriParam(defaultValue = "fetchX509Svid")
+    private SpiffeOperation operation = SpiffeOperation.fetchX509Svid;
+
+    @UriParam(label = "security")
+    private String spiffeSocketPath;
+
+    @UriParam
+    private String audience;
+
+    @UriParam(label = "advanced", description = "An existing WorkloadApiClient to use. When set, the component does not"
+                                                + " create or close its own client and spiffeSocketPath is ignored.")
+    private WorkloadApiClient workloadApiClient;
+
+    /**
+     * The operation to perform on the SPIFFE Workload API.
+     */

Review Comment:
   Added in 7bb3361 — via a separate `@Metadata(autowired = true)` rather than on `@UriParam` (that annotation has no `autowired` attribute; `@Metadata` is where the AWS/Azure SDK-client options carry it). The client is now autowired from the registry and the generated `spiffe.json` reflects `"autowired": true`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] CAMEL-23305: camel-spiffe - new component for SPIFFE workload identity (X.509-SVID / JWT-SVID) [camel]

Posted by "davsclaus (via GitHub)" <gi...@apache.org>.
davsclaus commented on code in PR #25621:
URL: https://github.com/apache/camel/pull/25621#discussion_r3843520866


##########
components/camel-spiffe/src/main/docs/spiffe-component.adoc:
##########
@@ -0,0 +1,80 @@
+= SPIFFE Component
+:doctitle: SPIFFE
+:shortname: spiffe
+:artifactid: camel-spiffe
+:description: Fetch and validate SPIFFE workload identity (X.509-SVID and JWT-SVID) from the SPIFFE Workload API.
+:since: 4.23
+:supportlevel: Preview
+:tabs-sync-option:
+:component-header: Only producer is supported
+
+*Since Camel {since}*
+
+*{component-header}*
+
+The SPIFFE component integrates with the https://spiffe.io/[SPIFFE] (Secure Production Identity Framework
+For Everyone) Workload API to provide cryptographic workload identity to Camel routes. It talks to a local
+SPIFFE Workload API endpoint — for example the one exposed by a https://spiffe.io/docs/latest/spire-about/[SPIRE]
+agent — to fetch and validate SVIDs (SPIFFE Verifiable Identity Documents):
+
+* *X.509-SVID*: an X.509 certificate whose SPIFFE ID is encoded as a URI SAN, used for mutual TLS.
+* *JWT-SVID*: a JWT whose subject is the SPIFFE ID, used as a bearer token for workload-to-workload authentication.
+
+Maven users will need to add the following dependency to their `pom.xml`.
+
+[source,xml]
+------------------------------------------------------------
+<dependency>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>camel-spiffe</artifactId>
+    <version>x.x.x</version>
+    <!-- use the same version as your Camel core version -->
+</dependency>
+------------------------------------------------------------
+
+== URI Format
+
+------------------------------------------------------------
+spiffe:label[?options]
+------------------------------------------------------------
+
+Where `label` is a logical name for the endpoint.
+
+// component options: START
+include::partial$component-configure-options.adoc[]
+include::partial$component-endpoint-options.adoc[]
+include::partial$component-endpoint-headers.adoc[]
+// component options: END
+
+== Workload API endpoint
+
+The address of the SPIFFE Workload API is taken from the `spiffeSocketPath` option, or, when that is not set, from
+the standard `SPIFFE_ENDPOINT_SOCKET` environment variable — for example `unix:///tmp/spire-agent/public/api.sock`.
+For advanced scenarios an already-configured `io.spiffe.workloadapi.WorkloadApiClient` can be supplied through the
+`workloadApiClient` option; in that case the component neither creates nor closes the client.
+
+== Operations
+
+The component supports the following producer operations:
+
+* `fetchX509Svid` — fetches the default X.509-SVID from the Workload API. The message body is set to the
+`io.spiffe.svid.x509svid.X509Svid` (certificate chain, private key and SPIFFE ID) and the `CamelSpiffeSpiffeId`
+header to its SPIFFE ID.
+* `fetchJwtSvid` — fetches a JWT-SVID for the configured `audience` (or the `CamelSpiffeAudience` header). The

Review Comment:
   Non-blocking doc suggestion: `fetchX509Svid` puts the private key on the message body. Since Camel's trust model treats route authors as fully trusted with Exchange contents, this isn't a framework issue, but a one-line warning here (e.g. "avoid logging/tracing the message body for this operation") would help users avoid accidentally leaking key material via `log`/`trace`/message-history EIPs.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org