oscerd commented on code in PR #27725:
URL: https://github.com/apache/camel/pull/27725#discussion_r4248499597


##########
components/camel-lra/src/main/java/org/apache/camel/service/lra/LRASagaService.java:
##########
@@ -84,17 +89,86 @@ public boolean isLongRunningActionHeaderSupported() {
         return true;
     }
 
+    /**
+     * Returns the coordinator of an LRA, which is joined, completed or 
compensated by calling its URL. Only an LRA
+     * hosted by the configured coordinator, or by one of the allowed 
coordinator URLs, is accepted.
+     */
     @Override
     public CompletableFuture<CamelSagaCoordinator> getSaga(String id) {
         CompletableFuture<CamelSagaCoordinator> coordinator;
         try {
-            coordinator = CompletableFuture.completedFuture(new 
LRASagaCoordinator(this, URI.create(id).toURL()));
+            URI lra = URI.create(id);
+            if (!isHostedByAllowedCoordinator(lra)) {
+                throw new IllegalArgumentException(
+                        "The Long-Running-Action " + id + " is not hosted by 
the LRA coordinator configured on the LRA"
+                                                   + " saga service. If it is 
a trusted coordinator, add its URL to"
+                                                   + " 
allowedCoordinatorUrls.");
+            }
+            coordinator = CompletableFuture.completedFuture(new 
LRASagaCoordinator(this, lra.toURL()));
         } catch (Exception ex) {
             coordinator = CompletableFuture.failedFuture(ex);
         }
         return coordinator;
     }
 
+    private boolean isHostedByAllowedCoordinator(URI lra) {
+        for (URI coordinator : allowedCoordinators()) {
+            if (isHostedBy(lra, coordinator)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * The URLs of the coordinators whose LRAs are accepted: the configured 
coordinator, and the allowed coordinator
+     * URLs.
+     */
+    private List<URI> allowedCoordinators() {

Review Comment:
   Thanks. I kept it computed per call on purpose: every accepted lookup is 
followed by an HTTP request to the coordinator (join, close or cancel), so 
parsing one or two URLs is noise next to it, and deriving the list from the 
current options avoids keeping a cache in sync with the setters. Happy to 
revisit if `allowedCoordinatorUrls` ever needs to hold many entries.
   
   _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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to