This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new c83db7589e73 CAMEL-26834: Support explicit local SPIFFE identity
selection (#29822)
c83db7589e73 is described below
commit c83db7589e73aa17ff934e348f2f0eb0c9750da7
Author: Andrea Cosentino <[email protected]>
AuthorDate: Mon Nov 16 22:54:27 2026 +0100
CAMEL-26834: Support explicit local SPIFFE identity selection (#29822)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-authored-by: Codex <[email protected]>
---
.../catalog/beans/SpiffeSSLContextParameters.json | 2 +-
.../apache/camel/catalog/components/spiffe.json | 10 +-
.../camel/catalog/docs/spiffe-component.adoc | 104 +++++++++
.../spiffe/SpiffeComponentConfigurer.java | 6 +
.../component/spiffe/SpiffeEndpointConfigurer.java | 6 +
.../component/spiffe/SpiffeEndpointUriFactory.java | 3 +-
.../SpiffeSSLContextParametersConfigurer.java | 6 +
.../org/apache/camel/component/spiffe/spiffe.json | 10 +-
.../camel/bean/SpiffeSSLContextParameters.json | 2 +-
.../src/main/docs/spiffe-component.adoc | 104 +++++++++
.../component/spiffe/SpiffeConfiguration.java | 18 ++
.../camel/component/spiffe/SpiffeEndpoint.java | 1 +
.../camel/component/spiffe/SpiffeProducer.java | 34 ++-
.../spiffe/SpiffeSSLContextParameters.java | 34 ++-
.../component/spiffe/SpiffeX509SvidSelector.java | 85 +++++++
.../component/spiffe/SpiffeLocalIdentityTest.java | 260 +++++++++++++++++++++
.../camel/component/spiffe/SpiffeProducerTest.java | 48 ++++
.../dsl/SpiffeComponentBuilderFactory.java | 23 ++
.../endpoint/dsl/SpiffeEndpointBuilderFactory.java | 21 ++
19 files changed, 757 insertions(+), 20 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/SpiffeSSLContextParameters.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/SpiffeSSLContextParameters.json
index ca445236ce47..2c8c80eb79f4 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/SpiffeSSLContextParameters.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/beans/SpiffeSSLContextParameters.json
@@ -10,7 +10,7 @@
"groupId": "org.apache.camel",
"artifactId": "camel-spiffe",
"version": "4.24.0-SNAPSHOT",
- "properties": { "spiffeSocketPath": { "index": 0, "kind": "property",
"displayName": "Spiffe Socket Path", "label": "security", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Path to the SPIFFE
Workload API endpoint (for example unix:\/\/\/tmp\/agent.sock). When not set,
the SPIFFE_ENDPOINT_SOCKET environment variable is used." },
"acceptedSpiffeIds": { "index": 1, "kind": "property", "dis [...]
+ "properties": { "spiffeSocketPath": { "index": 0, "kind": "property",
"displayName": "Spiffe Socket Path", "label": "security", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Path to the SPIFFE
Workload API endpoint (for example unix:\/\/\/tmp\/agent.sock). When not set,
the SPIFFE_ENDPOINT_SOCKET environment variable is used." },
"acceptedSpiffeIds": { "index": 1, "kind": "property", "dis [...]
}
}
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/spiffe.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/spiffe.json
index 69434d105cbc..b2dd3b8004a6 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/spiffe.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/spiffe.json
@@ -32,8 +32,9 @@
"autowiredEnabled": { "index": 5, "kind": "property", "displayName":
"Autowired Enabled", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": true, "description":
"Whether autowiring is enabled. This is used for automatic autowiring options
(the option must be marked as autowired) by looking up in the registry to find
if there is a single instance of matching t [...]
"workloadApiClient": { "index": 6, "kind": "property", "displayName":
"Workload Api Client", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType": "io.spiffe.workloadapi.WorkloadApiClient",
"deprecated": false, "autowired": true, "secret": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "An existing WorkloadApiClient to use. When
set, the component does not [...]
"allowOperationHeader": { "index": 7, "kind": "property", "displayName":
"Allow Operation Header", "group": "security", "label": "security", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "security": "insecure:dev",
"defaultValue": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "Whether the CamelSpiffeOperation header may
[...]
- "spiffeSocketPath": { "index": 8, "kind": "property", "displayName":
"Spiffe Socket Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "The address of the SPIFFE Workload API
endpoint (for example unix:\/\/\/tmp\/agent.sock or tcp [...]
- "x509Response": { "index": 9, "kind": "property", "displayName": "X509
Response", "group": "security", "label": "producer,security", "required":
false, "type": "enum", "javaType":
"org.apache.camel.component.spiffe.SpiffeX509Response", "enum": [ "svid",
"chain", "id" ], "deprecated": false, "autowired": false, "secret": false,
"defaultValue": "chain", "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": " [...]
+ "localSpiffeId": { "index": 8, "kind": "property", "displayName": "Local
Spiffe Id", "group": "security", "label": "producer,security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "The exact local SPIFFE ID to use when the
Workload API supplies several identities: fetchX5 [...]
+ "spiffeSocketPath": { "index": 9, "kind": "property", "displayName":
"Spiffe Socket Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "The address of the SPIFFE Workload API
endpoint (for example unix:\/\/\/tmp\/agent.sock or tcp [...]
+ "x509Response": { "index": 10, "kind": "property", "displayName": "X509
Response", "group": "security", "label": "producer,security", "required":
false, "type": "enum", "javaType":
"org.apache.camel.component.spiffe.SpiffeX509Response", "enum": [ "svid",
"chain", "id" ], "deprecated": false, "autowired": false, "secret": false,
"defaultValue": "chain", "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": [...]
},
"headers": {
"CamelSpiffeOperation": { "index": 0, "kind": "header", "displayName": "",
"group": "producer", "label": "producer", "required": false, "javaType":
"org.apache.camel.component.spiffe.SpiffeOperation or String", "deprecated":
false, "autowired": false, "secret": false, "description": "Overrides the
operation to be used by the producer. Ignored unless the endpoint sets
allowOperationHeader=true, because the operation decides whether the endpoint
validates a token or mints one.", "const [...]
@@ -54,7 +55,8 @@
"lazyStartProducer": { "index": 4, "kind": "parameter", "displayName":
"Lazy Start Producer", "group": "producer (advanced)", "label":
"producer,advanced", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Whether the producer should be started
lazy (on the first message). By starting lazy you can use this to allow
CamelContext and routes to startup in situations where a produc [...]
"workloadApiClient": { "index": 5, "kind": "parameter", "displayName":
"Workload Api Client", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType": "io.spiffe.workloadapi.WorkloadApiClient",
"deprecated": false, "autowired": true, "secret": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "An existing WorkloadApiClient to use. When
set, the component does no [...]
"allowOperationHeader": { "index": 6, "kind": "parameter", "displayName":
"Allow Operation Header", "group": "security", "label": "security", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "security": "insecure:dev",
"defaultValue": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "Whether the CamelSpiffeOperation header ma
[...]
- "spiffeSocketPath": { "index": 7, "kind": "parameter", "displayName":
"Spiffe Socket Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "The address of the SPIFFE Workload API
endpoint (for example unix:\/\/\/tmp\/agent.sock or tc [...]
- "x509Response": { "index": 8, "kind": "parameter", "displayName": "X509
Response", "group": "security", "label": "producer,security", "required":
false, "type": "enum", "javaType":
"org.apache.camel.component.spiffe.SpiffeX509Response", "enum": [ "svid",
"chain", "id" ], "deprecated": false, "autowired": false, "secret": false,
"defaultValue": "chain", "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": [...]
+ "localSpiffeId": { "index": 7, "kind": "parameter", "displayName": "Local
Spiffe Id", "group": "security", "label": "producer,security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "The exact local SPIFFE ID to use when the
Workload API supplies several identities: fetchX [...]
+ "spiffeSocketPath": { "index": 8, "kind": "parameter", "displayName":
"Spiffe Socket Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "The address of the SPIFFE Workload API
endpoint (for example unix:\/\/\/tmp\/agent.sock or tc [...]
+ "x509Response": { "index": 9, "kind": "parameter", "displayName": "X509
Response", "group": "security", "label": "producer,security", "required":
false, "type": "enum", "javaType":
"org.apache.camel.component.spiffe.SpiffeX509Response", "enum": [ "svid",
"chain", "id" ], "deprecated": false, "autowired": false, "secret": false,
"defaultValue": "chain", "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": [...]
}
}
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/spiffe-component.adoc
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/spiffe-component.adoc
index d14b43034d9a..40df966c744c 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/spiffe-component.adoc
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/spiffe-component.adoc
@@ -315,6 +315,110 @@ YAML::
----
====
+== Select a local X.509 identity
+
+A workload can receive several X.509-SVIDs from the Workload API. Set
`localSpiffeId` to choose an exact local
+identity instead of the default SVID. The producer's `fetchX509Svid` and
`fetchJwtSvid` operations and
+`SpiffeSSLContextParameters` all support this option. It is distinct from
`acceptedSpiffeIds`, which restricts *remote peers*: selecting a local
+identity does not broaden the TLS peer allow-list.
+
+The selector is route/bean configuration, never a message header or a
per-message expression. An invalid SPIFFE ID
+fails before opening the source. An identity that is missing does not fall
back to the default or another identity.
+`fetchJwtSvid` mints the JWT-SVID with `localSpiffeId` as its subject, and the
Workload API refuses a subject the
+workload is not entitled to, so the option fails closed there too.
`validateJwtSvid` has no local identity to choose
+and ignores it.
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("direct:identity")
+
.to("spiffe:identity?operation=fetchX509Svid&localSpiffeId=spiffe://example.org/billing&x509Response=id");
+----
+XML::
++
+[source,xml]
+----
+<route>
+ <from uri="direct:identity"/>
+ <to
uri="spiffe:identity?operation=fetchX509Svid&localSpiffeId=spiffe://example.org/billing&x509Response=id"/>
+</route>
+----
+YAML::
++
+[source,yaml]
+----
+- route:
+ from:
+ uri: direct:identity
+ steps:
+ - to:
+ uri:
"spiffe:identity?operation=fetchX509Svid&localSpiffeId=spiffe://example.org/billing&x509Response=id"
+----
+====
+
+The selected identity's normal `x509Response` behavior and identity/expiry
headers still apply. A fetch selects from
+the current Workload API context, so a rotated certificate for that same
identity is picked up on the next fetch.
+If the identity disappears, the fetch fails and clears its identity/expiry
outputs.
+
+For TLS, configure the same option on the SSL parameters bean:
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+SpiffeSSLContextParameters ssl = new SpiffeSSLContextParameters();
+ssl.setLocalSpiffeId("spiffe://example.org/billing");
+ssl.setAcceptedSpiffeIds("spiffe://example.org/backend");
+getContext().getRegistry().bind("billingSsl", ssl);
+
+from("direct:callBackend")
+ .to("https://backend.example.org/api?sslContextParameters=#billingSsl");
+----
+XML::
++
+[source,xml]
+----
+<bean id="billingSsl"
class="org.apache.camel.component.spiffe.SpiffeSSLContextParameters">
+ <property name="localSpiffeId" value="spiffe://example.org/billing"/>
+ <property name="acceptedSpiffeIds" value="spiffe://example.org/backend"/>
+</bean>
+<route>
+ <from uri="direct:callBackend"/>
+ <to uri="https://backend.example.org/api?sslContextParameters=#billingSsl"/>
+</route>
+----
+YAML::
++
+[source,yaml]
+----
+- beans:
+ - name: billingSsl
+ type: org.apache.camel.component.spiffe.SpiffeSSLContextParameters
+ properties:
+ localSpiffeId: spiffe://example.org/billing
+ acceptedSpiffeIds: spiffe://example.org/backend
+- route:
+ from:
+ uri: direct:callBackend
+ steps:
+ - to:
+ uri:
"https://backend.example.org/api?sslContextParameters=#billingSsl"
+----
+====
+
+The TLS source reselects on every Workload API update and retains only the
configured identity. It refuses to start
+if that identity is initially absent. If a later update removes it, reads of
the local TLS identity fail clearly;
+the source does not retain the old selected credential or silently choose
another. A subsequent update restoring
+the configured identity makes its new credential available again. Existing
established TLS sessions are not
+terminated by changing the source; this selection applies when JSSE asks for
the local identity. Configure
+`localSpiffeId` before creating the SSL context; changing the bean afterwards
does not replace its cached context.
+Leaving the option unset preserves the SDK's default selection.
+
== Authorizing a route on the peer SPIFFE ID (SpiffeSecurityPolicy)
`SpiffeSSLContextParameters` decides *which peers may connect*;
`org.apache.camel.component.spiffe.SpiffeSecurityPolicy`
diff --git
a/components/camel-spiffe/src/generated/java/org/apache/camel/component/spiffe/SpiffeComponentConfigurer.java
b/components/camel-spiffe/src/generated/java/org/apache/camel/component/spiffe/SpiffeComponentConfigurer.java
index 13d66f8a2f44..8b3d79f36ab1 100644
---
a/components/camel-spiffe/src/generated/java/org/apache/camel/component/spiffe/SpiffeComponentConfigurer.java
+++
b/components/camel-spiffe/src/generated/java/org/apache/camel/component/spiffe/SpiffeComponentConfigurer.java
@@ -39,6 +39,8 @@ public class SpiffeComponentConfigurer extends
PropertyConfigurerSupport impleme
case "configuration": target.setConfiguration(property(camelContext,
org.apache.camel.component.spiffe.SpiffeConfiguration.class, value)); return
true;
case "lazystartproducer":
case "lazyStartProducer":
target.setLazyStartProducer(property(camelContext, boolean.class, value));
return true;
+ case "localspiffeid":
+ case "localSpiffeId":
getOrCreateConfiguration(target).setLocalSpiffeId(property(camelContext,
java.lang.String.class, value)); return true;
case "operation":
getOrCreateConfiguration(target).setOperation(property(camelContext,
org.apache.camel.component.spiffe.SpiffeOperation.class, value)); return true;
case "preservebody":
case "preserveBody":
getOrCreateConfiguration(target).setPreserveBody(property(camelContext,
boolean.class, value)); return true;
@@ -68,6 +70,8 @@ public class SpiffeComponentConfigurer extends
PropertyConfigurerSupport impleme
case "configuration": return
org.apache.camel.component.spiffe.SpiffeConfiguration.class;
case "lazystartproducer":
case "lazyStartProducer": return boolean.class;
+ case "localspiffeid":
+ case "localSpiffeId": return java.lang.String.class;
case "operation": return
org.apache.camel.component.spiffe.SpiffeOperation.class;
case "preservebody":
case "preserveBody": return boolean.class;
@@ -93,6 +97,8 @@ public class SpiffeComponentConfigurer extends
PropertyConfigurerSupport impleme
case "configuration": return target.getConfiguration();
case "lazystartproducer":
case "lazyStartProducer": return target.isLazyStartProducer();
+ case "localspiffeid":
+ case "localSpiffeId": return
getOrCreateConfiguration(target).getLocalSpiffeId();
case "operation": return
getOrCreateConfiguration(target).getOperation();
case "preservebody":
case "preserveBody": return
getOrCreateConfiguration(target).isPreserveBody();
diff --git
a/components/camel-spiffe/src/generated/java/org/apache/camel/component/spiffe/SpiffeEndpointConfigurer.java
b/components/camel-spiffe/src/generated/java/org/apache/camel/component/spiffe/SpiffeEndpointConfigurer.java
index 69273dc83252..10c9d653393d 100644
---
a/components/camel-spiffe/src/generated/java/org/apache/camel/component/spiffe/SpiffeEndpointConfigurer.java
+++
b/components/camel-spiffe/src/generated/java/org/apache/camel/component/spiffe/SpiffeEndpointConfigurer.java
@@ -29,6 +29,8 @@ public class SpiffeEndpointConfigurer extends
PropertyConfigurerSupport implemen
case "audience":
target.getConfiguration().setAudience(property(camelContext,
java.lang.String.class, value)); return true;
case "lazystartproducer":
case "lazyStartProducer":
target.setLazyStartProducer(property(camelContext, boolean.class, value));
return true;
+ case "localspiffeid":
+ case "localSpiffeId":
target.getConfiguration().setLocalSpiffeId(property(camelContext,
java.lang.String.class, value)); return true;
case "operation":
target.getConfiguration().setOperation(property(camelContext,
org.apache.camel.component.spiffe.SpiffeOperation.class, value)); return true;
case "preservebody":
case "preserveBody":
target.getConfiguration().setPreserveBody(property(camelContext, boolean.class,
value)); return true;
@@ -55,6 +57,8 @@ public class SpiffeEndpointConfigurer extends
PropertyConfigurerSupport implemen
case "audience": return java.lang.String.class;
case "lazystartproducer":
case "lazyStartProducer": return boolean.class;
+ case "localspiffeid":
+ case "localSpiffeId": return java.lang.String.class;
case "operation": return
org.apache.camel.component.spiffe.SpiffeOperation.class;
case "preservebody":
case "preserveBody": return boolean.class;
@@ -77,6 +81,8 @@ public class SpiffeEndpointConfigurer extends
PropertyConfigurerSupport implemen
case "audience": return target.getConfiguration().getAudience();
case "lazystartproducer":
case "lazyStartProducer": return target.isLazyStartProducer();
+ case "localspiffeid":
+ case "localSpiffeId": return
target.getConfiguration().getLocalSpiffeId();
case "operation": return target.getConfiguration().getOperation();
case "preservebody":
case "preserveBody": return target.getConfiguration().isPreserveBody();
diff --git
a/components/camel-spiffe/src/generated/java/org/apache/camel/component/spiffe/SpiffeEndpointUriFactory.java
b/components/camel-spiffe/src/generated/java/org/apache/camel/component/spiffe/SpiffeEndpointUriFactory.java
index 86d4b10cd3aa..48689c10e14c 100644
---
a/components/camel-spiffe/src/generated/java/org/apache/camel/component/spiffe/SpiffeEndpointUriFactory.java
+++
b/components/camel-spiffe/src/generated/java/org/apache/camel/component/spiffe/SpiffeEndpointUriFactory.java
@@ -24,11 +24,12 @@ public class SpiffeEndpointUriFactory extends
org.apache.camel.support.component
private static final Set<String> ENDPOINT_IDENTITY_PROPERTY_NAMES;
private static final Map<String, String> MULTI_VALUE_PREFIXES;
static {
- Set<String> props = new HashSet<>(9);
+ Set<String> props = new HashSet<>(10);
props.add("allowOperationHeader");
props.add("audience");
props.add("label");
props.add("lazyStartProducer");
+ props.add("localSpiffeId");
props.add("operation");
props.add("preserveBody");
props.add("spiffeSocketPath");
diff --git
a/components/camel-spiffe/src/generated/java/org/apache/camel/component/spiffe/SpiffeSSLContextParametersConfigurer.java
b/components/camel-spiffe/src/generated/java/org/apache/camel/component/spiffe/SpiffeSSLContextParametersConfigurer.java
index dd711cd681aa..5164d221a8d0 100644
---
a/components/camel-spiffe/src/generated/java/org/apache/camel/component/spiffe/SpiffeSSLContextParametersConfigurer.java
+++
b/components/camel-spiffe/src/generated/java/org/apache/camel/component/spiffe/SpiffeSSLContextParametersConfigurer.java
@@ -32,6 +32,8 @@ public class SpiffeSSLContextParametersConfigurer extends
org.apache.camel.suppo
case "camelContext": target.setCamelContext(property(camelContext,
org.apache.camel.CamelContext.class, value)); return true;
case "inittimeout":
case "initTimeout": target.setInitTimeout(property(camelContext,
long.class, value)); return true;
+ case "localspiffeid":
+ case "localSpiffeId": target.setLocalSpiffeId(property(camelContext,
java.lang.String.class, value)); return true;
case "spiffesocketpath":
case "spiffeSocketPath":
target.setSpiffeSocketPath(property(camelContext, java.lang.String.class,
value)); return true;
default: return false;
@@ -49,6 +51,8 @@ public class SpiffeSSLContextParametersConfigurer extends
org.apache.camel.suppo
case "camelContext": return org.apache.camel.CamelContext.class;
case "inittimeout":
case "initTimeout": return long.class;
+ case "localspiffeid":
+ case "localSpiffeId": return java.lang.String.class;
case "spiffesocketpath":
case "spiffeSocketPath": return java.lang.String.class;
default: return null;
@@ -67,6 +71,8 @@ public class SpiffeSSLContextParametersConfigurer extends
org.apache.camel.suppo
case "camelContext": return target.getCamelContext();
case "inittimeout":
case "initTimeout": return target.getInitTimeout();
+ case "localspiffeid":
+ case "localSpiffeId": return target.getLocalSpiffeId();
case "spiffesocketpath":
case "spiffeSocketPath": return target.getSpiffeSocketPath();
default: return null;
diff --git
a/components/camel-spiffe/src/generated/resources/META-INF/org/apache/camel/component/spiffe/spiffe.json
b/components/camel-spiffe/src/generated/resources/META-INF/org/apache/camel/component/spiffe/spiffe.json
index 69434d105cbc..b2dd3b8004a6 100644
---
a/components/camel-spiffe/src/generated/resources/META-INF/org/apache/camel/component/spiffe/spiffe.json
+++
b/components/camel-spiffe/src/generated/resources/META-INF/org/apache/camel/component/spiffe/spiffe.json
@@ -32,8 +32,9 @@
"autowiredEnabled": { "index": 5, "kind": "property", "displayName":
"Autowired Enabled", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": true, "description":
"Whether autowiring is enabled. This is used for automatic autowiring options
(the option must be marked as autowired) by looking up in the registry to find
if there is a single instance of matching t [...]
"workloadApiClient": { "index": 6, "kind": "property", "displayName":
"Workload Api Client", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType": "io.spiffe.workloadapi.WorkloadApiClient",
"deprecated": false, "autowired": true, "secret": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "An existing WorkloadApiClient to use. When
set, the component does not [...]
"allowOperationHeader": { "index": 7, "kind": "property", "displayName":
"Allow Operation Header", "group": "security", "label": "security", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "security": "insecure:dev",
"defaultValue": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "Whether the CamelSpiffeOperation header may
[...]
- "spiffeSocketPath": { "index": 8, "kind": "property", "displayName":
"Spiffe Socket Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "The address of the SPIFFE Workload API
endpoint (for example unix:\/\/\/tmp\/agent.sock or tcp [...]
- "x509Response": { "index": 9, "kind": "property", "displayName": "X509
Response", "group": "security", "label": "producer,security", "required":
false, "type": "enum", "javaType":
"org.apache.camel.component.spiffe.SpiffeX509Response", "enum": [ "svid",
"chain", "id" ], "deprecated": false, "autowired": false, "secret": false,
"defaultValue": "chain", "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": " [...]
+ "localSpiffeId": { "index": 8, "kind": "property", "displayName": "Local
Spiffe Id", "group": "security", "label": "producer,security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "The exact local SPIFFE ID to use when the
Workload API supplies several identities: fetchX5 [...]
+ "spiffeSocketPath": { "index": 9, "kind": "property", "displayName":
"Spiffe Socket Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "The address of the SPIFFE Workload API
endpoint (for example unix:\/\/\/tmp\/agent.sock or tcp [...]
+ "x509Response": { "index": 10, "kind": "property", "displayName": "X509
Response", "group": "security", "label": "producer,security", "required":
false, "type": "enum", "javaType":
"org.apache.camel.component.spiffe.SpiffeX509Response", "enum": [ "svid",
"chain", "id" ], "deprecated": false, "autowired": false, "secret": false,
"defaultValue": "chain", "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": [...]
},
"headers": {
"CamelSpiffeOperation": { "index": 0, "kind": "header", "displayName": "",
"group": "producer", "label": "producer", "required": false, "javaType":
"org.apache.camel.component.spiffe.SpiffeOperation or String", "deprecated":
false, "autowired": false, "secret": false, "description": "Overrides the
operation to be used by the producer. Ignored unless the endpoint sets
allowOperationHeader=true, because the operation decides whether the endpoint
validates a token or mints one.", "const [...]
@@ -54,7 +55,8 @@
"lazyStartProducer": { "index": 4, "kind": "parameter", "displayName":
"Lazy Start Producer", "group": "producer (advanced)", "label":
"producer,advanced", "required": false, "type": "boolean", "javaType":
"boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Whether the producer should be started
lazy (on the first message). By starting lazy you can use this to allow
CamelContext and routes to startup in situations where a produc [...]
"workloadApiClient": { "index": 5, "kind": "parameter", "displayName":
"Workload Api Client", "group": "advanced", "label": "advanced", "required":
false, "type": "object", "javaType": "io.spiffe.workloadapi.WorkloadApiClient",
"deprecated": false, "autowired": true, "secret": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "An existing WorkloadApiClient to use. When
set, the component does no [...]
"allowOperationHeader": { "index": 6, "kind": "parameter", "displayName":
"Allow Operation Header", "group": "security", "label": "security", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "security": "insecure:dev",
"defaultValue": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "Whether the CamelSpiffeOperation header ma
[...]
- "spiffeSocketPath": { "index": 7, "kind": "parameter", "displayName":
"Spiffe Socket Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "The address of the SPIFFE Workload API
endpoint (for example unix:\/\/\/tmp\/agent.sock or tc [...]
- "x509Response": { "index": 8, "kind": "parameter", "displayName": "X509
Response", "group": "security", "label": "producer,security", "required":
false, "type": "enum", "javaType":
"org.apache.camel.component.spiffe.SpiffeX509Response", "enum": [ "svid",
"chain", "id" ], "deprecated": false, "autowired": false, "secret": false,
"defaultValue": "chain", "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": [...]
+ "localSpiffeId": { "index": 7, "kind": "parameter", "displayName": "Local
Spiffe Id", "group": "security", "label": "producer,security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "The exact local SPIFFE ID to use when the
Workload API supplies several identities: fetchX [...]
+ "spiffeSocketPath": { "index": 8, "kind": "parameter", "displayName":
"Spiffe Socket Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": "The address of the SPIFFE Workload API
endpoint (for example unix:\/\/\/tmp\/agent.sock or tc [...]
+ "x509Response": { "index": 9, "kind": "parameter", "displayName": "X509
Response", "group": "security", "label": "producer,security", "required":
false, "type": "enum", "javaType":
"org.apache.camel.component.spiffe.SpiffeX509Response", "enum": [ "svid",
"chain", "id" ], "deprecated": false, "autowired": false, "secret": false,
"defaultValue": "chain", "configurationClass":
"org.apache.camel.component.spiffe.SpiffeConfiguration", "configurationField":
"configuration", "description": [...]
}
}
diff --git
a/components/camel-spiffe/src/generated/resources/META-INF/services/org/apache/camel/bean/SpiffeSSLContextParameters.json
b/components/camel-spiffe/src/generated/resources/META-INF/services/org/apache/camel/bean/SpiffeSSLContextParameters.json
index ca445236ce47..2c8c80eb79f4 100644
---
a/components/camel-spiffe/src/generated/resources/META-INF/services/org/apache/camel/bean/SpiffeSSLContextParameters.json
+++
b/components/camel-spiffe/src/generated/resources/META-INF/services/org/apache/camel/bean/SpiffeSSLContextParameters.json
@@ -10,7 +10,7 @@
"groupId": "org.apache.camel",
"artifactId": "camel-spiffe",
"version": "4.24.0-SNAPSHOT",
- "properties": { "spiffeSocketPath": { "index": 0, "kind": "property",
"displayName": "Spiffe Socket Path", "label": "security", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Path to the SPIFFE
Workload API endpoint (for example unix:\/\/\/tmp\/agent.sock). When not set,
the SPIFFE_ENDPOINT_SOCKET environment variable is used." },
"acceptedSpiffeIds": { "index": 1, "kind": "property", "dis [...]
+ "properties": { "spiffeSocketPath": { "index": 0, "kind": "property",
"displayName": "Spiffe Socket Path", "label": "security", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "Path to the SPIFFE
Workload API endpoint (for example unix:\/\/\/tmp\/agent.sock). When not set,
the SPIFFE_ENDPOINT_SOCKET environment variable is used." },
"acceptedSpiffeIds": { "index": 1, "kind": "property", "dis [...]
}
}
diff --git a/components/camel-spiffe/src/main/docs/spiffe-component.adoc
b/components/camel-spiffe/src/main/docs/spiffe-component.adoc
index d14b43034d9a..40df966c744c 100644
--- a/components/camel-spiffe/src/main/docs/spiffe-component.adoc
+++ b/components/camel-spiffe/src/main/docs/spiffe-component.adoc
@@ -315,6 +315,110 @@ YAML::
----
====
+== Select a local X.509 identity
+
+A workload can receive several X.509-SVIDs from the Workload API. Set
`localSpiffeId` to choose an exact local
+identity instead of the default SVID. The producer's `fetchX509Svid` and
`fetchJwtSvid` operations and
+`SpiffeSSLContextParameters` all support this option. It is distinct from
`acceptedSpiffeIds`, which restricts *remote peers*: selecting a local
+identity does not broaden the TLS peer allow-list.
+
+The selector is route/bean configuration, never a message header or a
per-message expression. An invalid SPIFFE ID
+fails before opening the source. An identity that is missing does not fall
back to the default or another identity.
+`fetchJwtSvid` mints the JWT-SVID with `localSpiffeId` as its subject, and the
Workload API refuses a subject the
+workload is not entitled to, so the option fails closed there too.
`validateJwtSvid` has no local identity to choose
+and ignores it.
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("direct:identity")
+
.to("spiffe:identity?operation=fetchX509Svid&localSpiffeId=spiffe://example.org/billing&x509Response=id");
+----
+XML::
++
+[source,xml]
+----
+<route>
+ <from uri="direct:identity"/>
+ <to
uri="spiffe:identity?operation=fetchX509Svid&localSpiffeId=spiffe://example.org/billing&x509Response=id"/>
+</route>
+----
+YAML::
++
+[source,yaml]
+----
+- route:
+ from:
+ uri: direct:identity
+ steps:
+ - to:
+ uri:
"spiffe:identity?operation=fetchX509Svid&localSpiffeId=spiffe://example.org/billing&x509Response=id"
+----
+====
+
+The selected identity's normal `x509Response` behavior and identity/expiry
headers still apply. A fetch selects from
+the current Workload API context, so a rotated certificate for that same
identity is picked up on the next fetch.
+If the identity disappears, the fetch fails and clears its identity/expiry
outputs.
+
+For TLS, configure the same option on the SSL parameters bean:
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+SpiffeSSLContextParameters ssl = new SpiffeSSLContextParameters();
+ssl.setLocalSpiffeId("spiffe://example.org/billing");
+ssl.setAcceptedSpiffeIds("spiffe://example.org/backend");
+getContext().getRegistry().bind("billingSsl", ssl);
+
+from("direct:callBackend")
+ .to("https://backend.example.org/api?sslContextParameters=#billingSsl");
+----
+XML::
++
+[source,xml]
+----
+<bean id="billingSsl"
class="org.apache.camel.component.spiffe.SpiffeSSLContextParameters">
+ <property name="localSpiffeId" value="spiffe://example.org/billing"/>
+ <property name="acceptedSpiffeIds" value="spiffe://example.org/backend"/>
+</bean>
+<route>
+ <from uri="direct:callBackend"/>
+ <to uri="https://backend.example.org/api?sslContextParameters=#billingSsl"/>
+</route>
+----
+YAML::
++
+[source,yaml]
+----
+- beans:
+ - name: billingSsl
+ type: org.apache.camel.component.spiffe.SpiffeSSLContextParameters
+ properties:
+ localSpiffeId: spiffe://example.org/billing
+ acceptedSpiffeIds: spiffe://example.org/backend
+- route:
+ from:
+ uri: direct:callBackend
+ steps:
+ - to:
+ uri:
"https://backend.example.org/api?sslContextParameters=#billingSsl"
+----
+====
+
+The TLS source reselects on every Workload API update and retains only the
configured identity. It refuses to start
+if that identity is initially absent. If a later update removes it, reads of
the local TLS identity fail clearly;
+the source does not retain the old selected credential or silently choose
another. A subsequent update restoring
+the configured identity makes its new credential available again. Existing
established TLS sessions are not
+terminated by changing the source; this selection applies when JSSE asks for
the local identity. Configure
+`localSpiffeId` before creating the SSL context; changing the bean afterwards
does not replace its cached context.
+Leaving the option unset preserves the SDK's default selection.
+
== Authorizing a route on the peer SPIFFE ID (SpiffeSecurityPolicy)
`SpiffeSSLContextParameters` decides *which peers may connect*;
`org.apache.camel.component.spiffe.SpiffeSecurityPolicy`
diff --git
a/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeConfiguration.java
b/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeConfiguration.java
index 57e4bc99fea5..00d7df3ea2e6 100644
---
a/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeConfiguration.java
+++
b/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeConfiguration.java
@@ -31,6 +31,9 @@ public class SpiffeConfiguration implements Cloneable {
@UriParam(label = "producer,security", defaultValue = "chain")
private SpiffeX509Response x509Response = SpiffeX509Response.chain;
+ @UriParam(label = "producer,security")
+ private String localSpiffeId;
+
@UriParam(label = "security")
private String spiffeSocketPath;
@@ -76,6 +79,21 @@ public class SpiffeConfiguration implements Cloneable {
this.x509Response = x509Response;
}
+ public String getLocalSpiffeId() {
+ return localSpiffeId;
+ }
+
+ /**
+ * The exact local SPIFFE ID to use when the Workload API supplies several
identities: fetchX509Svid selects that
+ * X.509-SVID instead of the SDK's default one, and fetchJwtSvid mints the
JWT-SVID with it as the subject. A
+ * configured identity that is absent, or that the workload is not
entitled to, fails without selecting a different
+ * identity. This option comes only from endpoint configuration, never
from a message header; validateJwtSvid has no
+ * local identity to choose and ignores it.
+ */
+ public void setLocalSpiffeId(String localSpiffeId) {
+ this.localSpiffeId = localSpiffeId;
+ }
+
/**
* The address of the SPIFFE Workload API endpoint (for example {@code
unix:///tmp/agent.sock} or
* {@code tcp://127.0.0.1:8082}). When not set, the {@code
SPIFFE_ENDPOINT_SOCKET} environment variable is used.
diff --git
a/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeEndpoint.java
b/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeEndpoint.java
index 660c4e73c8e5..953203fd112b 100644
---
a/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeEndpoint.java
+++
b/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeEndpoint.java
@@ -79,6 +79,7 @@ public class SpiffeEndpoint extends DefaultEndpoint {
@Override
protected void doStart() throws Exception {
super.doStart();
+ SpiffeX509SvidSelector.parse(configuration.getLocalSpiffeId());
if (configuration.getWorkloadApiClient() != null) {
workloadApiClient = configuration.getWorkloadApiClient();
ownClient = false;
diff --git
a/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeProducer.java
b/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeProducer.java
index 5018738e2502..3e4e9c63acfd 100644
---
a/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeProducer.java
+++
b/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeProducer.java
@@ -18,18 +18,22 @@ package org.apache.camel.component.spiffe;
import java.util.Arrays;
+import io.spiffe.spiffeid.SpiffeId;
import io.spiffe.svid.jwtsvid.JwtSvid;
import io.spiffe.svid.x509svid.X509Svid;
import io.spiffe.workloadapi.WorkloadApiClient;
+import io.spiffe.workloadapi.X509Context;
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 {
+ private final SpiffeId localSpiffeId;
public SpiffeProducer(final SpiffeEndpoint endpoint) {
super(endpoint);
+ localSpiffeId =
SpiffeX509SvidSelector.parse(endpoint.getConfiguration().getLocalSpiffeId());
}
@Override
@@ -49,8 +53,16 @@ public class SpiffeProducer extends DefaultProducer {
}
private void fetchX509Svid(WorkloadApiClient client, Exchange exchange)
throws Exception {
- X509Svid svid = client.fetchX509Context().getDefaultSvid();
Message message = getMessageForResponse(exchange);
+ // a fetch that fails, with or without a configured identity, must not
leave the identity of an earlier
+ // message behind
+ message.removeHeader(SpiffeConstants.SPIFFE_ID);
+ message.removeHeader(SpiffeConstants.EXPIRY);
+ X509Context context = client.fetchX509Context();
+ X509Svid svid = localSpiffeId == null
+ ? context.getDefaultSvid()
+ : SpiffeX509SvidSelector.require(
+ SpiffeX509SvidSelector.select(context.getX509Svids(),
localSpiffeId), localSpiffeId);
// the identity is always available through the headers, so a route
that only needs it can avoid the key
message.setHeader(SpiffeConstants.SPIFFE_ID,
svid.getSpiffeId().toString());
message.setHeader(SpiffeConstants.EXPIRY,
svid.getLeaf().getNotAfter());
@@ -67,11 +79,23 @@ public class SpiffeProducer extends DefaultProducer {
}
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);
+ // cleared before anything that can fail, the audience resolution
included, as on the X.509 path
+ message.removeHeader(SpiffeConstants.SPIFFE_ID);
+ message.removeHeader(SpiffeConstants.EXPIRY);
+ String[] audiences = resolveAudiences(exchange);
+ JwtSvid svid;
+ if (localSpiffeId == null) {
+ svid = audiences.length > 1
+ ? client.fetchJwtSvid(audiences[0],
Arrays.copyOfRange(audiences, 1, audiences.length))
+ : client.fetchJwtSvid(audiences[0]);
+ } else {
+ // the configured identity is the subject of the token; the
Workload API refuses a subject the workload
+ // is not entitled to, so the option fails closed here as it does
for X.509
+ svid = audiences.length > 1
+ ? client.fetchJwtSvid(localSpiffeId, audiences[0],
Arrays.copyOfRange(audiences, 1, audiences.length))
+ : client.fetchJwtSvid(localSpiffeId, audiences[0]);
+ }
message.setBody(svid.getToken());
message.setHeader(SpiffeConstants.SPIFFE_ID,
svid.getSpiffeId().toString());
message.setHeader(SpiffeConstants.EXPIRY, svid.getExpiry());
diff --git
a/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeSSLContextParameters.java
b/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeSSLContextParameters.java
index ff335444ff5a..bf8e6d1a8724 100644
---
a/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeSSLContextParameters.java
+++
b/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeSSLContextParameters.java
@@ -79,6 +79,11 @@ public class SpiffeSSLContextParameters extends
SSLContextParameters implements
description = "Comma-separated allow-list of peer SPIFFE IDs to
accept during the TLS handshake"
+ " (for example spiffe://example.org/client).
Mutually exclusive with acceptAnySpiffeId.")
private String acceptedSpiffeIds;
+ @Metadata(label = "security",
+ description = "Exact local SPIFFE ID to use for TLS when the
Workload API supplies multiple X.509-SVIDs."
+ + " Defaults to the SDK's default SVID. If
configured, an absent or removed identity fails"
+ + " without falling back to another local
identity. This does not select accepted peers.")
+ private String localSpiffeId;
@Metadata(label = "security", defaultValue = "false", security =
"insecure:ssl",
description = "Accept any peer SPIFFE ID that validates against
the trust bundle, instead of an"
+ " explicit acceptedSpiffeIds allow-list. This
authenticates the trust domain but not"
@@ -105,6 +110,15 @@ public class SpiffeSSLContextParameters extends
SSLContextParameters implements
this.spiffeSocketPath = spiffeSocketPath;
}
+ public String getLocalSpiffeId() {
+ return localSpiffeId;
+ }
+
+ /** Select the local TLS identity by exact SPIFFE ID; unrelated to the
peer allow-list. */
+ public void setLocalSpiffeId(String localSpiffeId) {
+ this.localSpiffeId = localSpiffeId;
+ }
+
public String getAcceptedSpiffeIds() {
return acceptedSpiffeIds;
}
@@ -180,7 +194,8 @@ public class SpiffeSSLContextParameters extends
SSLContextParameters implements
protocol = DEFAULT_PROTOCOL;
}
- X509Source source = createX509Source();
+ SpiffeId requested =
SpiffeX509SvidSelector.parse(parsePropertyValue(localSpiffeId));
+ X509Source source = createX509Source(requested);
X509SourceService service = new X509SourceService(source);
try {
SslContextOptions.SslContextOptionsBuilder options
@@ -210,16 +225,27 @@ public class SpiffeSSLContextParameters extends
SSLContextParameters implements
}
}
- private X509Source createX509Source() {
+ private X509Source createX509Source(SpiffeId requested) {
+ X509Source source = null;
try {
X509SourceOptions.Builder builder =
X509SourceOptions.builder().initTimeout(Duration.ofMillis(initTimeout));
if (ObjectHelper.isNotEmpty(spiffeSocketPath)) {
builder.spiffeSocketPath(parsePropertyValue(spiffeSocketPath));
}
- return DefaultX509Source.newSource(builder.build());
+ if (requested != null) {
+ builder.svidPicker(svids ->
SpiffeX509SvidSelector.select(svids, requested));
+ }
+ source = DefaultX509Source.newSource(builder.build());
+ if (requested == null) {
+ return source;
+ }
+ X509Source selected = SpiffeX509SvidSelector.guard(source,
requested);
+ selected.getX509Svid();
+ return selected;
} catch (Exception e) {
+ closeQuietly(source);
throw new RuntimeCamelException(
- "Could not create the SPIFFE X509Source (is a Workload API
endpoint reachable?)", e);
+ "Could not create the SPIFFE X509Source (check Workload
API availability and localSpiffeId)", e);
}
}
diff --git
a/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeX509SvidSelector.java
b/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeX509SvidSelector.java
new file mode 100644
index 000000000000..8357c2a3f2f3
--- /dev/null
+++
b/components/camel-spiffe/src/main/java/org/apache/camel/component/spiffe/SpiffeX509SvidSelector.java
@@ -0,0 +1,85 @@
+/*
+ * 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.io.IOException;
+import java.util.List;
+
+import io.spiffe.bundle.x509bundle.X509Bundle;
+import io.spiffe.exception.BundleNotFoundException;
+import io.spiffe.exception.InvalidSpiffeIdException;
+import io.spiffe.spiffeid.SpiffeId;
+import io.spiffe.spiffeid.TrustDomain;
+import io.spiffe.svid.x509svid.X509Svid;
+import io.spiffe.workloadapi.X509Source;
+import org.apache.camel.util.ObjectHelper;
+
+/** Exact local identity selection shared by the producer and the rotating TLS
source. */
+final class SpiffeX509SvidSelector {
+ private SpiffeX509SvidSelector() {
+ }
+
+ static SpiffeId parse(String configured) {
+ if (ObjectHelper.isEmpty(configured)) {
+ return null;
+ }
+ try {
+ return SpiffeId.parse(configured.trim());
+ } catch (InvalidSpiffeIdException e) {
+ throw new IllegalArgumentException("localSpiffeId must be an exact
SPIFFE ID", e);
+ }
+ }
+
+ static X509Svid select(List<X509Svid> svids, SpiffeId requested) {
+ if (svids != null) {
+ for (X509Svid svid : svids) {
+ if (svid != null && requested.equals(svid.getSpiffeId())) {
+ return svid;
+ }
+ }
+ }
+ // The SDK picker must publish a missing selected SVID on removal,
rather than retain its previous snapshot.
+ return null;
+ }
+
+ static X509Svid require(X509Svid svid, SpiffeId requested) {
+ if (svid == null || !requested.equals(svid.getSpiffeId())) {
+ throw new IllegalStateException(
+ "Configured local SPIFFE ID " + requested + " is not
present in the Workload API X.509 context");
+ }
+ return svid;
+ }
+
+ static X509Source guard(X509Source source, SpiffeId requested) {
+ return new X509Source() {
+ @Override
+ public X509Svid getX509Svid() {
+ return require(source.getX509Svid(), requested);
+ }
+
+ @Override
+ public X509Bundle getBundleForTrustDomain(TrustDomain trustDomain)
throws BundleNotFoundException {
+ return source.getBundleForTrustDomain(trustDomain);
+ }
+
+ @Override
+ public void close() throws IOException {
+ source.close();
+ }
+ };
+ }
+}
diff --git
a/components/camel-spiffe/src/test/java/org/apache/camel/component/spiffe/SpiffeLocalIdentityTest.java
b/components/camel-spiffe/src/test/java/org/apache/camel/component/spiffe/SpiffeLocalIdentityTest.java
new file mode 100644
index 000000000000..d029f01243c6
--- /dev/null
+++
b/components/camel-spiffe/src/test/java/org/apache/camel/component/spiffe/SpiffeLocalIdentityTest.java
@@ -0,0 +1,260 @@
+/*
+ * 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.security.cert.X509Certificate;
+import java.time.Duration;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.net.ssl.SSLContext;
+
+import io.spiffe.bundle.x509bundle.X509BundleSet;
+import io.spiffe.provider.SpiffeSslContextFactory;
+import io.spiffe.provider.SpiffeSslContextFactory.SslContextOptions;
+import io.spiffe.spiffeid.SpiffeId;
+import io.spiffe.svid.x509svid.X509Svid;
+import io.spiffe.workloadapi.DefaultX509Source;
+import io.spiffe.workloadapi.DefaultX509Source.X509SourceOptions;
+import io.spiffe.workloadapi.Watcher;
+import io.spiffe.workloadapi.WorkloadApiClient;
+import io.spiffe.workloadapi.X509Context;
+import io.spiffe.workloadapi.X509Source;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.RuntimeCamelException;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.support.DefaultExchange;
+import org.junit.jupiter.api.Test;
+import org.mockito.MockedStatic;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.mockStatic;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+class SpiffeLocalIdentityTest {
+ private static final String DEFAULT = "spiffe://example.org/default";
+ private static final String SELECTED = "spiffe://example.org/selected";
+
+ @Test
+ void selectsTheConfiguredIdentityAndIgnoresIdentityHeaders() throws
Exception {
+ try (CamelContext context = new DefaultCamelContext()) {
+ X509Svid defaultSvid = svid(DEFAULT, 1);
+ X509Svid selected = svid(SELECTED, 2);
+ WorkloadApiClient client = mock(WorkloadApiClient.class);
+ when(client.fetchX509Context()).thenReturn(x509(defaultSvid,
selected));
+ SpiffeProducer producer = producer(context, client, SELECTED);
+ Exchange exchange = new DefaultExchange(context);
+ exchange.getMessage().setHeader(SpiffeConstants.SPIFFE_ID,
DEFAULT);
+ exchange.getMessage().setHeader("CamelSpiffeLocalSpiffeId",
DEFAULT);
+ producer.process(exchange);
+
assertThat(exchange.getMessage().getBody()).isSameAs(selected.getChain());
+
assertThat(exchange.getMessage().getHeader(SpiffeConstants.SPIFFE_ID)).isEqualTo(SELECTED);
+
assertThat(exchange.getMessage().getHeader(SpiffeConstants.EXPIRY)).isEqualTo(selected.getLeaf().getNotAfter());
+ }
+ }
+
+ @Test
+ void retainsDefaultSelectionWhenUnset() throws Exception {
+ try (CamelContext context = new DefaultCamelContext()) {
+ X509Svid defaultSvid = svid(DEFAULT, 1);
+ X509Context update = mock(X509Context.class);
+ when(update.getDefaultSvid()).thenReturn(defaultSvid);
+ WorkloadApiClient client = mock(WorkloadApiClient.class);
+ when(client.fetchX509Context()).thenReturn(update);
+ Exchange exchange = new DefaultExchange(context);
+ producer(context, client, null).process(exchange);
+
assertThat(exchange.getMessage().getHeader(SpiffeConstants.SPIFFE_ID)).isEqualTo(DEFAULT);
+ verify(update, never()).getX509Svids();
+ }
+ }
+
+ @Test
+ void selectionTracksRotationAndFailsOnRemovalWithoutStaleOutputs() throws
Exception {
+ try (CamelContext context = new DefaultCamelContext()) {
+ X509Svid defaultSvid = svid(DEFAULT, 1);
+ X509Svid first = svid(SELECTED, 2);
+ X509Svid rotated = svid(SELECTED, 3);
+ WorkloadApiClient client = mock(WorkloadApiClient.class);
+ when(client.fetchX509Context()).thenReturn(x509(defaultSvid,
first), x509(rotated, defaultSvid), x509(defaultSvid));
+ SpiffeProducer producer = producer(context, client, SELECTED);
+ Exchange exchange = new DefaultExchange(context);
+ producer.process(exchange);
+
assertThat(exchange.getMessage().getBody()).isSameAs(first.getChain());
+ producer.process(exchange);
+
assertThat(exchange.getMessage().getBody()).isSameAs(rotated.getChain());
+ assertThatThrownBy(() ->
producer.process(exchange)).isInstanceOf(IllegalStateException.class)
+ .hasMessageContaining(SELECTED).hasMessageContaining("not
present");
+
assertThat(exchange.getMessage().getHeader(SpiffeConstants.SPIFFE_ID)).isNull();
+
assertThat(exchange.getMessage().getHeader(SpiffeConstants.EXPIRY)).isNull();
+ }
+ }
+
+ @Test
+ void rejectsMalformedLocalIdentityBeforeFetchingMaterials() throws
Exception {
+ try (CamelContext context = new DefaultCamelContext()) {
+ WorkloadApiClient client = mock(WorkloadApiClient.class);
+ assertThatThrownBy(() -> producer(context, client,
"not-a-spiffe-id"))
+ .isInstanceOf(IllegalArgumentException.class);
+ verify(client, never()).fetchX509Context();
+ }
+ }
+
+ @Test
+ void tlsOptionsUseTheSelectorAndGuardTheSource() throws Exception {
+ DefaultX509Source source = mock(DefaultX509Source.class);
+ X509Svid defaultSvid = svid(DEFAULT, 1);
+ X509Svid selected = svid(SELECTED, 2);
+ when(source.getX509Svid()).thenReturn(selected);
+ AtomicReference<X509SourceOptions> seenSource = new
AtomicReference<>();
+ AtomicReference<SslContextOptions> seenTls = new AtomicReference<>();
+ try (CamelContext context = new DefaultCamelContext();
+ MockedStatic<DefaultX509Source> factory =
mockStatic(DefaultX509Source.class);
+ MockedStatic<SpiffeSslContextFactory> tls =
mockStatic(SpiffeSslContextFactory.class)) {
+ factory.when(() ->
DefaultX509Source.newSource(any(X509SourceOptions.class))).thenAnswer(invocation
-> {
+ seenSource.set(invocation.getArgument(0));
+ return source;
+ });
+ SSLContext defaultContext = SSLContext.getDefault();
+ tls.when(() ->
SpiffeSslContextFactory.getSslContext(any(SslContextOptions.class))).thenAnswer(invocation
-> {
+ seenTls.set(invocation.getArgument(0));
+ return defaultContext;
+ });
+ SpiffeSSLContextParameters parameters = new
SpiffeSSLContextParameters();
+ parameters.setAcceptedSpiffeIds("spiffe://example.org/peer");
+ parameters.setLocalSpiffeId(SELECTED);
+ parameters.createSSLContext(context);
+
+
assertThat(seenSource.get().getSvidPicker().apply(List.of(defaultSvid,
selected))).isSameAs(selected);
+
assertThat(seenSource.get().getSvidPicker().apply(List.of(defaultSvid))).isNull();
+ X509Source guarded = seenTls.get().getX509Source();
+ assertThat(guarded.getX509Svid()).isSameAs(selected);
+ when(source.getX509Svid()).thenReturn(null);
+
assertThatThrownBy(guarded::getX509Svid).isInstanceOf(IllegalStateException.class)
+ .hasMessageContaining(SELECTED);
+ }
+ verify(source).close();
+ }
+
+ @Test
+ void initiallyMissingTlsIdentityClosesTheOpenedSource() throws Exception {
+ DefaultX509Source source = mock(DefaultX509Source.class);
+ try (MockedStatic<DefaultX509Source> factory =
mockStatic(DefaultX509Source.class)) {
+ factory.when(() ->
DefaultX509Source.newSource(any(X509SourceOptions.class))).thenReturn(source);
+ SpiffeSSLContextParameters parameters = new
SpiffeSSLContextParameters();
+ parameters.setAcceptAnySpiffeId(true);
+ parameters.setLocalSpiffeId(SELECTED);
+ assertThatThrownBy(() ->
parameters.createSSLContext(null)).isInstanceOf(RuntimeCamelException.class)
+ .hasRootCauseMessage("Configured local SPIFFE ID " +
SELECTED
+ + " is not present in the Workload
API X.509 context");
+ verify(source).close();
+ }
+ }
+
+ @Test
+ void unsetTlsSelectorPreservesTheSdkDefaultPicker() throws Exception {
+ DefaultX509Source source = mock(DefaultX509Source.class);
+ AtomicReference<X509SourceOptions> seen = new AtomicReference<>();
+ try (CamelContext context = new DefaultCamelContext();
+ MockedStatic<DefaultX509Source> factory =
mockStatic(DefaultX509Source.class);
+ MockedStatic<SpiffeSslContextFactory> tls =
mockStatic(SpiffeSslContextFactory.class)) {
+ factory.when(() ->
DefaultX509Source.newSource(any(X509SourceOptions.class))).thenAnswer(invocation
-> {
+ seen.set(invocation.getArgument(0));
+ return source;
+ });
+ SSLContext defaultContext = SSLContext.getDefault();
+ tls.when(() ->
SpiffeSslContextFactory.getSslContext(any(SslContextOptions.class))).thenReturn(defaultContext);
+ SpiffeSSLContextParameters parameters = new
SpiffeSSLContextParameters();
+ parameters.setAcceptAnySpiffeId(true);
+ parameters.createSSLContext(context);
+ assertThat(seen.get().getSvidPicker()).isNull();
+ verify(source, never()).getX509Svid();
+ }
+ verify(source).close();
+ }
+
+ @Test
+ void malformedTlsSelectorFailsBeforeOpeningASource() {
+ try (MockedStatic<DefaultX509Source> factory =
mockStatic(DefaultX509Source.class)) {
+ SpiffeSSLContextParameters parameters = new
SpiffeSSLContextParameters();
+ parameters.setAcceptAnySpiffeId(true);
+ parameters.setLocalSpiffeId("not-a-spiffe-id");
+ assertThatThrownBy(() ->
parameters.createSSLContext(null)).isInstanceOf(IllegalArgumentException.class)
+ .hasMessageContaining("localSpiffeId");
+ factory.verifyNoInteractions();
+ }
+ }
+
+ @Test
+ void actualSdkSourcePublishesRemovalAndRotatesWithoutFallingBack() throws
Exception {
+ X509Svid defaultSvid = svid(DEFAULT, 1);
+ X509Svid selected = svid(SELECTED, 2);
+ X509Svid rotated = svid(SELECTED, 3);
+ WorkloadApiClient client = mock(WorkloadApiClient.class);
+ AtomicReference<Watcher<X509Context>> updates = new
AtomicReference<>();
+ doAnswer(invocation -> {
+ Watcher<X509Context> watcher = invocation.getArgument(0);
+ updates.set(watcher);
+ watcher.onUpdate(x509(defaultSvid, selected));
+ return null;
+ }).when(client).watchX509Context(any());
+ SpiffeId requested = SpiffeId.parse(SELECTED);
+ X509SourceOptions options =
X509SourceOptions.builder().workloadApiClient(client).initTimeout(Duration.ofSeconds(1))
+ .svidPicker(svids -> SpiffeX509SvidSelector.select(svids,
requested)).build();
+ try (X509Source source =
SpiffeX509SvidSelector.guard(DefaultX509Source.newSource(options), requested)) {
+ assertThat(source.getX509Svid()).isSameAs(selected);
+ updates.get().onUpdate(x509(defaultSvid));
+
assertThatThrownBy(source::getX509Svid).isInstanceOf(IllegalStateException.class)
+ .hasMessageContaining(SELECTED);
+ updates.get().onUpdate(x509(rotated, defaultSvid));
+ assertThat(source.getX509Svid()).isSameAs(rotated);
+ }
+ }
+
+ private static X509Svid svid(String id, int generation) throws Exception {
+ X509Svid svid = mock(X509Svid.class);
+ X509Certificate certificate = mock(X509Certificate.class);
+ when(certificate.getNotAfter()).thenReturn(new Date(2000000000000L +
generation));
+ when(svid.getSpiffeId()).thenReturn(SpiffeId.parse(id));
+ when(svid.getLeaf()).thenReturn(certificate);
+ when(svid.getChain()).thenReturn(List.of(certificate));
+ return svid;
+ }
+
+ private static X509Context x509(X509Svid... svids) {
+ return X509Context.of(List.of(svids), X509BundleSet.emptySet());
+ }
+
+ private static SpiffeProducer producer(CamelContext context,
WorkloadApiClient client, String localSpiffeId) {
+ SpiffeConfiguration configuration = new SpiffeConfiguration();
+ configuration.setLocalSpiffeId(localSpiffeId);
+ SpiffeEndpoint endpoint = new SpiffeEndpoint("spiffe:selection", new
SpiffeComponent(context), configuration) {
+ @Override
+ public WorkloadApiClient getWorkloadApiClient() {
+ return client;
+ }
+ };
+ return new SpiffeProducer(endpoint);
+ }
+}
diff --git
a/components/camel-spiffe/src/test/java/org/apache/camel/component/spiffe/SpiffeProducerTest.java
b/components/camel-spiffe/src/test/java/org/apache/camel/component/spiffe/SpiffeProducerTest.java
index 6fc5e99ee5c1..b944471a35aa 100644
---
a/components/camel-spiffe/src/test/java/org/apache/camel/component/spiffe/SpiffeProducerTest.java
+++
b/components/camel-spiffe/src/test/java/org/apache/camel/component/spiffe/SpiffeProducerTest.java
@@ -32,6 +32,8 @@ import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
class SpiffeProducerTest extends CamelTestSupport {
@@ -137,6 +139,52 @@ class SpiffeProducerTest extends CamelTestSupport {
assertThat(out.getMessage().getHeader(SpiffeConstants.EXPIRY)).isEqualTo(expiry);
}
+ @Test
+ void fetchJwtSvidMintsTheTokenForTheConfiguredLocalIdentity() throws
Exception {
+ SpiffeId billing = SpiffeId.parse("spiffe://example.org/billing");
+ SpiffeId id = spiffeId("spiffe://example.org/billing");
+ Date expiry = new Date();
+ JwtSvid svid = mock(JwtSvid.class);
+ when(svid.getToken()).thenReturn("the-billing-token");
+ when(svid.getSpiffeId()).thenReturn(id);
+ when(svid.getExpiry()).thenReturn(expiry);
+ when(client.fetchJwtSvid(billing, "my-audience")).thenReturn(svid);
+
+ Exchange out = template.request(
+
"spiffe:test?workloadApiClient=#client&operation=fetchJwtSvid&audience=my-audience"
+ +
"&localSpiffeId=spiffe://example.org/billing",
+ e -> e.getMessage().setHeader(SpiffeConstants.SPIFFE_ID,
"stale-identity"));
+
+
assertThat(out.getMessage().getBody(String.class)).isEqualTo("the-billing-token");
+
assertThat(out.getMessage().getHeader(SpiffeConstants.SPIFFE_ID)).isEqualTo("spiffe://example.org/billing");
+
assertThat(out.getMessage().getHeader(SpiffeConstants.EXPIRY)).isEqualTo(expiry);
+ // the default identity is never asked for
+ verify(client, never()).fetchJwtSvid("my-audience");
+ }
+
+ @Test
+ void fetchJwtSvidClearsTheIdentityHeadersWhenItFails() throws Exception {
+ when(client.fetchJwtSvid("my-audience")).thenThrow(new
IllegalStateException("workload api down"));
+
+ Exchange failed = template.request(
+
"spiffe:test?workloadApiClient=#client&operation=fetchJwtSvid&audience=my-audience",
e -> {
+ e.getMessage().setHeader(SpiffeConstants.SPIFFE_ID,
"stale-identity");
+ e.getMessage().setHeader(SpiffeConstants.EXPIRY, new
Date());
+ });
+
assertThat(failed.getException()).isInstanceOf(IllegalStateException.class);
+
assertThat(failed.getMessage().getHeader(SpiffeConstants.SPIFFE_ID)).isNull();
+
assertThat(failed.getMessage().getHeader(SpiffeConstants.EXPIRY)).isNull();
+
+ // the same when the audience is missing, which fails before the
Workload API is asked
+ Exchange noAudience =
template.request("spiffe:test?workloadApiClient=#client&operation=fetchJwtSvid",
e -> {
+ e.getMessage().setHeader(SpiffeConstants.SPIFFE_ID,
"stale-identity");
+ e.getMessage().setHeader(SpiffeConstants.EXPIRY, new Date());
+ });
+ assertThat(noAudience.getException()).isNotNull();
+
assertThat(noAudience.getMessage().getHeader(SpiffeConstants.SPIFFE_ID)).isNull();
+
assertThat(noAudience.getMessage().getHeader(SpiffeConstants.EXPIRY)).isNull();
+ }
+
@Test
void fetchJwtSvidAudienceFromHeader() throws Exception {
SpiffeId id = spiffeId("spiffe://example.org/workload");
diff --git
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/SpiffeComponentBuilderFactory.java
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/SpiffeComponentBuilderFactory.java
index 0b5c2ea51b8e..fb31aa2e8f81 100644
---
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/SpiffeComponentBuilderFactory.java
+++
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/SpiffeComponentBuilderFactory.java
@@ -213,6 +213,28 @@ public interface SpiffeComponentBuilderFactory {
return this;
}
+ /**
+ * The exact local SPIFFE ID to use when the Workload API supplies
+ * several identities: fetchX509Svid selects that X.509-SVID instead of
+ * the SDK's default one, and fetchJwtSvid mints the JWT-SVID with it
as
+ * the subject. A configured identity that is absent, or that the
+ * workload is not entitled to, fails without selecting a different
+ * identity. This option comes only from endpoint configuration, never
+ * from a message header; validateJwtSvid has no local identity to
+ * choose and ignores it.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: security
+ *
+ * @param localSpiffeId the value to set
+ * @return the dsl builder
+ */
+ default SpiffeComponentBuilder localSpiffeId(java.lang.String
localSpiffeId) {
+ doSetProperty("localSpiffeId", localSpiffeId);
+ return this;
+ }
+
/**
* The address of the SPIFFE Workload API endpoint (for example
* unix:///tmp/agent.sock or tcp://127.0.0.1:8082). When not set, the
@@ -282,6 +304,7 @@ public interface SpiffeComponentBuilderFactory {
case "autowiredEnabled": ((SpiffeComponent)
component).setAutowiredEnabled((boolean) value); return true;
case "workloadApiClient":
getOrCreateConfiguration((SpiffeComponent)
component).setWorkloadApiClient((io.spiffe.workloadapi.WorkloadApiClient)
value); return true;
case "allowOperationHeader":
getOrCreateConfiguration((SpiffeComponent)
component).setAllowOperationHeader((boolean) value); return true;
+ case "localSpiffeId": getOrCreateConfiguration((SpiffeComponent)
component).setLocalSpiffeId((java.lang.String) value); return true;
case "spiffeSocketPath":
getOrCreateConfiguration((SpiffeComponent)
component).setSpiffeSocketPath((java.lang.String) value); return true;
case "x509Response": getOrCreateConfiguration((SpiffeComponent)
component).setX509Response((org.apache.camel.component.spiffe.SpiffeX509Response)
value); return true;
default: return false;
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SpiffeEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SpiffeEndpointBuilderFactory.java
index a2bdcbc73f93..b0e64e0f6c6a 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SpiffeEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/SpiffeEndpointBuilderFactory.java
@@ -172,6 +172,27 @@ public interface SpiffeEndpointBuilderFactory {
doSetProperty("allowOperationHeader", allowOperationHeader);
return this;
}
+ /**
+ * The exact local SPIFFE ID to use when the Workload API supplies
+ * several identities: fetchX509Svid selects that X.509-SVID instead of
+ * the SDK's default one, and fetchJwtSvid mints the JWT-SVID with it
as
+ * the subject. A configured identity that is absent, or that the
+ * workload is not entitled to, fails without selecting a different
+ * identity. This option comes only from endpoint configuration, never
+ * from a message header; validateJwtSvid has no local identity to
+ * choose and ignores it.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: security
+ *
+ * @param localSpiffeId the value to set
+ * @return the dsl builder
+ */
+ default SpiffeEndpointBuilder localSpiffeId(String localSpiffeId) {
+ doSetProperty("localSpiffeId", localSpiffeId);
+ return this;
+ }
/**
* The address of the SPIFFE Workload API endpoint (for example
* unix:///tmp/agent.sock or tcp://127.0.0.1:8082). When not set, the