Skip to content

CAMEL-25994: camel-undertow - WebSocket: keep the OAuth validation of a connection per endpoint, like the other security checks - #28297

Merged
davsclaus merged 1 commit into
mainfrom
fix/CAMEL-25994
Oct 23, 2026
Merged

davsclaus merged 1 commit into
mainfrom
fix/CAMEL-25994

Conversation

@davsclaus

@davsclaus davsclaus commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

CAMEL-25994

CamelWebSocketHandler records, for each WebSocket connection, which endpoints of the path the handshake was checked against: the security provider, the allowed roles and the custom handlers of a consumer are kept per endpoint URI. The result of the oauthProfile validation was kept without the endpoint that did the validation, so the later checks of an open connection only saw that some OAuth validation had happened.

Changes:

  • The handshake result also records the endpoints whose OAuth profile validated the connection.
  • isAuthenticated requires the OAuth validation of the endpoint whose settings currently apply to the path. A connection validated by another endpoint no longer passes the checks of the path: it is closed with 1008 as soon as the new consumer is set (by the closePeersThatNoLongerPassChecks of CAMEL-25917: camel-undertow - a WebSocket connection accepted while only a producer served the path is not treated as having passed a later consumer's custom handlers #28237), and until then it is not sent messages nor served.
  • New test UndertowWsOAuthProfileConsumerChangeTest: a producer route keeps the path registered while the consumer is replaced by one with another OAuth profile. The old connection is closed when the new consumer starts, and the new one keeps working. It fails without the change.

Notes:

Tests: mvn verify in components/camel-undertow passes locally after the rebase (239 tests, 1 skipped).

Claude Code on behalf of @davsclaus

🤖 Generated with Claude Code

@davsclaus davsclaus added this to the 4.24.0 milestone Oct 22, 2026
@davsclaus davsclaus added the port/camel-4.22.x Bug needs porting to camel-4.22.x label Oct 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 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 have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@gnodet-bot gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The fix correctly scopes OAuth validation per endpoint rather than globally across the path.

The oauthEndpoints set is populated during the upgrade handshake and carried in HandshakeResult.oauthEndpointUris. The new isOAuthValidated() then requires the current endpoint's URI to be in that set — so a connection validated by oauthProfile=first is correctly rejected by oauthProfile=second when the consumer changes. The channel-null case is handled correctly: isOAuthValidated returns false when channel == null, preserving the original null-guard behavior.

The test is well-structured. The 1008 close on firstWebSocket.sendText() is triggered by UndertowConsumer.rejectUnauthenticatedWebSocketChannel() which calls CamelWebSocketHandler.isAuthenticated(channel, getEndpoint()) — that's the public single-arg overload routed through the new isOAuthValidated. The test correctly exercises the fixed code path.

Pre-fix validation: ⚠️ dynamic check skipped (build takes too long, Undertow integration tests require a live server). Static trace confirms: test → sendText() → onFullTextMessage() → consumer.sendMessage() → rejectUnauthenticatedWebSocketChannel() → isAuthenticated() → isOAuthValidated() — the method modified by the fix. The test assertion (MSG_VIOLATES_POLICY close code + empty first.received) would only pass if isOAuthValidated returns false for the endpoint whose URI was not stored during the original handshake, which it does without the fix. Confirmed red-without-fix by static trace.

Backport label port/camel-4.22.x is correctly set — camel-4.18.x does not have WebSocket oauthProfile support so LTS backport is not applicable.

This review was generated by an AI agent, Hermès on behalf of @gnodet.

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-undertow

ℹ️ 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.


🔬 Scalpel shadow comparison — Scalpel: 46 of 707 tested, 27 compile-only — current: 46 all tested

Maveniverse Scalpel detected 46 affected modules (current approach: 46).

Skip-tests mode would test 46 modules (1 direct + 45 downstream), skip tests for 27 (generated code, meta-modules)

Modules Scalpel would test (46)
  • camel-a2a ← downstream of org.apache.camel:camel-vertx-http
  • camel-ai-observability ← downstream of org.apache.camel:camel-telemetry
  • camel-consul ← downstream of org.apache.camel:camel-undertow
  • camel-cxf-rest ← downstream of org.apache.camel:camel-undertow
  • camel-cxf-soap ← downstream of org.apache.camel:camel-undertow
  • camel-cxf-spring-rest ← downstream of org.apache.camel:camel-undertow
  • camel-cxf-spring-soap ← downstream of org.apache.camel:camel-undertow
  • camel-cxf-spring-transport ← downstream of org.apache.camel:camel-cxf-transport
  • camel-cxf-transport ← downstream of org.apache.camel:camel-undertow
  • camel-jbang-mcp ← downstream of org.apache.camel:camel-rest-openapi
  • camel-jbang-plugin-mcp ← downstream of org.apache.camel:camel-jbang-core
  • camel-jbang-plugin-tui ← downstream of org.apache.camel:camel-catalog
  • camel-jbang-plugin-validate ← downstream of org.apache.camel:camel-jbang-core
  • camel-jsonpath ← downstream of org.apache.camel:camel-platform-http-vertx
  • camel-knative-http ← downstream of org.apache.camel:camel-platform-http-vertx
  • camel-langchain4j-agent ← downstream of org.apache.camel:camel-telemetry
  • camel-langchain4j-chat ← downstream of org.apache.camel:camel-telemetry
  • camel-langchain4j-embeddings ← downstream of org.apache.camel:camel-telemetry
  • camel-langchain4j-embeddingstore ← downstream of org.apache.camel:camel-langchain4j-embeddings
  • camel-launcher-container ← downstream of org.apache.camel:camel-launcher
  • camel-lra ← downstream of org.apache.camel:camel-undertow
  • camel-mcp-server ← downstream of org.apache.camel:camel-openai
  • camel-micrometer-observability ← downstream of org.apache.camel:camel-undertow
  • camel-micrometer-prometheus ← downstream of org.apache.camel:camel-platform-http-main
  • camel-oauth ← downstream of org.apache.camel:camel-undertow
  • camel-observability-services ← downstream of org.apache.camel:camel-opentelemetry2
  • camel-openai ← downstream of org.apache.camel:camel-telemetry
  • camel-openapi-validator ← downstream of org.apache.camel:camel-rest-openapi
  • camel-opentelemetry ← downstream of org.apache.camel:camel-undertow
  • camel-opentelemetry2 ← downstream of org.apache.camel:camel-undertow
  • camel-platform-http-main ← downstream of org.apache.camel:camel-platform-http-vertx
  • camel-platform-http-vertx ← downstream of org.apache.camel:camel-vertx-http
  • camel-rest-openapi ← downstream of org.apache.camel:camel-undertow
  • camel-rest-postman ← downstream of org.apache.camel:camel-vertx-http
  • camel-semantic-openai ← downstream of org.apache.camel:camel-openai
  • camel-slack ← downstream of org.apache.camel:camel-undertow
  • camel-soap ← downstream of org.apache.camel:camel-cxf-soap
  • camel-spring-ai-chat ← downstream of org.apache.camel:camel-telemetry
  • camel-telemetry ← downstream of org.apache.camel:camel-undertow
  • camel-telemetry-dev ← downstream of org.apache.camel:camel-undertow
  • camel-undertow ← components/camel-undertow/src/main/java/org/apache/camel/component/undertow/handlers/CamelWebSocketHandler.java, components/camel-undertow/src/test/java/org/apache/camel/component/undertow/ws/UndertowWsOAuthProfileConsumerChangeTest.java
  • camel-undertow-spring-security ← downstream of org.apache.camel:camel-undertow
  • camel-vertx-http ← downstream of org.apache.camel:camel-undertow
  • camel-yaml-dsl-validator ← downstream of org.apache.camel:camel-catalog
  • camel-yaml-dsl-validator-maven-plugin ← downstream of org.apache.camel:camel-yaml-dsl-validator
  • camel-zookeeper ← downstream of org.apache.camel:camel-undertow
Modules with tests skipped (27)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • 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

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more


⚙️ View full build and test results

… a connection per endpoint, like the other security checks

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com>
@davsclaus davsclaus self-assigned this Oct 23, 2026
@davsclaus davsclaus added the bug Something isn't working label Oct 23, 2026
@davsclaus
davsclaus merged commit f4ea671 into main Oct 23, 2026
6 checks passed
@davsclaus
davsclaus deleted the fix/CAMEL-25994 branch October 23, 2026 08:45
@gnodet

gnodet commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

🔄 Backport Bot

Conflicts (🤖 agent dispatched to resolve):

  • ⚠️ camel-4.22.x — Cherry-pick conflict in: components/camel-undertow/src/main/java/org/apache/camel/component/undertow/handlers/CamelWebSocketHandler.java

ℹ️ If you push additional commits after /port, use /port again to update the port PRs.

@gnodet

gnodet commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

✅ Backport to camel-4.22.x created: #28337

@gnodet gnodet removed the port/camel-4.22.x Bug needs porting to camel-4.22.x label Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants