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

   ## CAMEL-25917: camel-undertow WebSocket consumer handlers and a connection 
opened before the consumer started
   
   ### Problem
   
   In `camel-undertow`, the consumer and the producers of a WebSocket path 
share one `CamelWebSocketHandler`. When a
   handshake passes the security checks of the path, the handler records, per 
channel, the set of endpoint URIs whose
   checks passed. The checks depend on whether a consumer is registered: the 
custom `handlers` an endpoint configures are
   run only for consumers, so while only a producer serves the path they are 
skipped.
   
   The recorded result did not note which mode the handshake ran in. On a path 
whose producer applies a security provider
   or allowed roles, a connection could be accepted while only the producer 
served the path, before its consumer was
   started for the first time. That handshake ran the producer checks and 
recorded the endpoint URI, but not the custom
   `handlers`. Once a consumer configuring `handlers` on the same endpoint URI 
was started, the recorded URI was treated
   as proof that the consumer checks had passed, so messages from that 
connection reached the consumer route and the
   connection kept receiving what the producer sent, without the consumer 
`handlers` ever being applied to it.
   
   This follows up on CAMEL-25375, which made the `handlers`, security provider 
and allowed roles apply to WebSocket
   consumers.
   
   ### Change
   
   `HandshakeResult` now records whether the handshake ran in consumer mode. 
`isAuthenticated(...)` requires, for an
   endpoint whose consumer configures `handlers`, that the recorded result came 
from a consumer-mode handshake; a result
   recorded while only producers served the path is no longer sufficient. 
Producer-only behaviour is unchanged (producers
   still do not run `handlers`), and connections that go through the consumer 
handlers are served as before.
   
   A connection accepted before a consumer with `handlers` was first started is 
now not served once that consumer is up:
   its messages no longer reach the route and it no longer receives producer 
output, and it is closed, exactly as the
   existing fail-closed handling already does for the security-provider and 
OAuth cases. Clients opening a connection in
   that window must reconnect after the consumer has started. An upgrade-guide 
note for 4.24 describes this.
   
   ### Tests
   
   New `SecurityProviderWebSocketConsumerHandlersWindowTest` in 
`components/camel-undertow`:
   
   - `connectionAcceptedBeforeAConsumerWithHandlersStartedIsNotServed` - a path 
whose producer applies `allowedRoles` and
     whose consumer adds `handlers` on the same endpoint URI; a connection 
opened while only the producer serves the path
     is closed once the consumer starts, its messages do not reach the route, 
and it receives no producer broadcast. This
     test fails before the change (the connection is served and never closed) 
and passes after it.
   - `connectionThatRunsTheConsumerHandlersIsServed` - a regression guard: a 
connection that goes through the consumer
     handlers after the consumer started is served.
   
   The full `camel-undertow` module test suite passes.
   


-- 
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