Andrea Cosentino created CAMEL-26340:
----------------------------------------
Summary: camel-lra: validate coordinator URL returned when
starting a new saga against allowed coordinators
Key: CAMEL-26340
URL: https://issues.apache.org/jira/browse/CAMEL-26340
Project: Camel
Issue Type: Bug
Components: camel-lra
Reporter: Andrea Cosentino
Assignee: Andrea Cosentino
Fix For: 4.24.0, 4.22.3, 4.18.6
h3. Current behaviour
In {{LRASagaService.newSaga(Exchange)}} (camel-lra), when starting a new LRA,
the URL returned by the coordinator is used directly to create
{{LRASagaCoordinator}}:
{code:java}
@Override
public CompletableFuture<CamelSagaCoordinator> newSaga(Exchange exchange) {
return client.newLRA(exchange)
.thenApply(url -> new LRASagaCoordinator(LRASagaService.this, url));
}
{code}
In contrast, {{getSaga(String id)}} validates that the coordinator URL is
hosted by the configured coordinator or listed in {{allowedCoordinatorUrls}}
before instantiating the coordinator:
{code:java}
URI lra = URI.create(id);
if (!isHostedByAllowedCoordinator(lra)) {
throw new IllegalArgumentException(...);
}
{code}
Because {{newSaga}} does not perform this check, an LRA URL returned when
starting a saga is joined, completed, or compensated without verifying that its
host, port, and context path match the configured coordinator or allowed
coordinator URLs.
h3. Expected behaviour
{{LRASagaService.newSaga(Exchange)}} should validate that the URL returned by
the coordinator is hosted by the configured coordinator or an allowed
coordinator URL via {{isHostedByAllowedCoordinator}} before constructing the
{{LRASagaCoordinator}}.
h3. Change
In {{LRASagaService.newSaga(Exchange)}}, verify the URL returned by
{{client.newLRA(exchange)}} using {{isHostedByAllowedCoordinator}} and fail
with {{IllegalArgumentException}} if the URL is not hosted by an allowed
coordinator.
h3. Tests
Add tests in {{camel-lra}} verifying that {{newSaga}} rejects a coordinator
start response returning a URL with an unconfigured host, port, or path outside
the coordinator context path, and accepts an allowed coordinator URL.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)