Skip to content

[backport camel-4.22.x] CAMEL-25706, CAMEL-25707, CAMEL-25708: camel-elasticsearch, camel-elasticsearch-rest-client, camel-opensearch - bind the basic authentication credentials to the cluster nodes - #28050

Merged
davsclaus merged 3 commits into
apache:camel-4.22.xfrom
oscerd:backport/CAMEL-25706-25708-to-camel-4.22.x
Oct 18, 2026

Conversation

@oscerd

@oscerd oscerd commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

Backport of #27949 (CAMEL-25707), #27948 (CAMEL-25708) and #27946 (CAMEL-25706) to camel-4.22.x. These are straight cherry-picks of the merged commits f8bd57d57c79, 004809689f98 and 442e440e43e6, in merge order.

Compared with the original PRs, only the upgrade-guide hunks differ.

Tests

  • Full reactor mvn clean install -DskipTests -DskipITs on this branch: green, no generated-file changes.
  • Module tests pass:
Module Tests
camel-elasticsearch 19
camel-elasticsearch-rest-client 16
camel-opensearch 19

Claude Code on behalf of oscerd

🤖 Generated with Claude Code

oscerd and others added 3 commits October 18, 2026 12:15
…ication credentials to the cluster nodes

[CAMEL-25707](https://issues.apache.org/jira/browse/CAMEL-25707): `ElasticsearchRestClientProducer.createClient()` registered the configured `user` and `password` with `AuthScope.ANY`, which matches any host.

- The credentials are now held by a `NodeScopedCredentialsProvider`, which offers them only to the nodes the client talks to: the hosts of `hostAddressesList` and, when `enableSniffer` is set, the nodes the sniffer finds.
- A node matches on scheme, host name (in any case) and port. A node without a port matches the default port of its scheme.
- The provider reads the nodes from the `RestClient` (`getNodes()`) on each lookup, so it follows the nodes the sniffer adds or removes. Every configured node keeps receiving the credentials.
- HttpClient 4's `BasicCredentialsProvider` matches an `AuthScope` on host and port only, never on the scheme. The provider therefore checks the origin of the scope that HttpClient looks the credentials up with, both preemptively and after a challenge.
- `setCredentials` and `clear` do nothing, because the credentials come from the endpoint configuration only. HttpClient calls `setCredentials` for the user info of a request URI.
- A client set with the `restClient` option is not changed.

This is the same change as apache#27946 (CAMEL-25706) for camel-elasticsearch. The provider class is duplicated because the two components are separate modules.

Closes apache#27949

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f8bd57d)
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
…ials to the cluster nodes

[CAMEL-25708](https://issues.apache.org/jira/browse/CAMEL-25708): `OpensearchProducer.createClient()` registered the configured `user` and `password` with `new AuthScope(null, null, -1, null, null)`, which matches any host. [CAMEL-24815](https://issues.apache.org/jira/browse/CAMEL-24815) switched to it so that every node of a multi-host cluster receives the credentials, not only the first configured host.

- The credentials are now held by a `NodeScopedCredentialsProvider`, which offers them only to the nodes the client talks to: the hosts of `hostAddresses` and, when `enableSniffer` is set, the nodes the sniffer finds. Every configured node keeps receiving them, as CAMEL-24815 intended.
- A node matches on scheme, host name (in any case) and port. A node without a port matches the default port of its scheme.
- The provider reads the nodes from the `RestClient` (`getNodes()`) on each lookup, so it follows the nodes the sniffer adds or removes.
- A client set with the `client` or `openSearchClient` option is not changed.

This is the same change as apache#27946 (CAMEL-25706) for camel-elasticsearch. Here it is written against HttpClient 5, whose `CredentialsProvider` only looks credentials up, and whose `AuthScope` carries the scheme (`getProtocol()`).

Upgrade guide (4.24): a request to another host is sent without the credentials. This includes the host of a node with another scheme or port.

Closes apache#27948

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 0048096)
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
…entials to the cluster nodes

[CAMEL-25706](https://issues.apache.org/jira/browse/CAMEL-25706): `ElasticsearchProducer.createClient()` registered the configured `user` and `password` with `AuthScope.ANY`, which matches any host.

- The credentials are now held by a `NodeScopedCredentialsProvider`, which offers them only to the nodes the client talks to: the hosts of `hostAddresses` and, when `enableSniffer` is set, the nodes the sniffer finds.
- A node matches on scheme, host name (in any case) and port. A node without a port matches the default port of its scheme.
- The provider reads the nodes from the `RestClient` (`getNodes()`) on each lookup, so it follows the nodes the sniffer adds or removes. Every configured node keeps receiving the credentials.
- HttpClient 4's `BasicCredentialsProvider` matches an `AuthScope` on host and port only, never on the scheme. The provider therefore checks the origin of the scope that HttpClient looks the credentials up with, both preemptively and after a challenge.
- `setCredentials` and `clear` do nothing, because the credentials come from the endpoint configuration only. HttpClient calls `setCredentials` for the user info of a request URI.
- A client set with the `client` option is not changed.

Closes apache#27946

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 442e440)
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
@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. Clean backport of #27946, #27948, #27949 to camel-4.22.x.

The three NodeScopedCredentialsProvider implementations are correctly adapted to their respective HttpClient versions (HC4 for camel-elasticsearch and camel-elasticsearch-rest-client, HC5 for camel-opensearch). The AtomicReference pattern has a safe null-check fallback for the initialization window. Test coverage is thorough: provider unit tests (matching, rejection, dynamic sniffer nodes, null scopes), producer factory unit tests, and end-to-end integration tests using a real HTTP server for the rest-client and opensearch modules. The camel-elasticsearch module intentionally lacks the end-to-end test, consistent with the original PR on main.

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

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-elasticsearch-rest-client
  • components/camel-elasticsearch
  • components/camel-opensearch

🔬 Scalpel shadow comparison — Scalpel: 11 tested, 29 compile-only — current: 11 all tested

Maveniverse Scalpel detected 40 affected modules (current approach: 11).

⚠️ Modules only in Scalpel (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • 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

Skip-tests mode would test 11 modules (3 direct + 8 downstream), skip tests for 29 (generated code, meta-modules)

Modules Scalpel would test (11)
  • camel-elasticsearch
  • camel-elasticsearch-rest-client
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
  • camel-opensearch
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin
Modules with tests skipped (29)
  • apache-camel
  • camel-allcomponents
  • camel-catalog
  • camel-catalog-console
  • camel-catalog-lucene
  • camel-catalog-maven
  • camel-catalog-suggest
  • camel-componentdsl
  • camel-csimple-maven-plugin
  • 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

All tested modules (40 modules)
  • Camel :: All Components Sync point
  • Camel :: Assembly
  • Camel :: Catalog :: CSimple Maven Plugin (deprecated)
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Catalog :: Camel Report Maven Plugin
  • Camel :: Catalog :: Camel Route Parser
  • Camel :: Catalog :: Console
  • Camel :: Catalog :: Dummy Component
  • Camel :: Catalog :: Lucene (deprecated)
  • Camel :: Catalog :: Maven
  • Camel :: Catalog :: Suggest
  • Camel :: Component DSL
  • Camel :: Coverage
  • Camel :: Docs
  • Camel :: ElasticSearch Rest Client
  • Camel :: Elasticsearch Java API Client
  • Camel :: Endpoint DSL
  • Camel :: Endpoint DSL :: Support
  • Camel :: Integration Tests
  • Camel :: JBang :: Core
  • Camel :: JBang :: Integration tests
  • Camel :: JBang :: MCP
  • Camel :: JBang :: Main
  • Camel :: JBang :: Plugin :: Edit
  • Camel :: JBang :: Plugin :: Generate
  • Camel :: JBang :: Plugin :: Kubernetes
  • Camel :: JBang :: Plugin :: MCP
  • Camel :: JBang :: Plugin :: Route Parser
  • Camel :: JBang :: Plugin :: TUI
  • Camel :: JBang :: Plugin :: Testing
  • Camel :: JBang :: Plugin :: Validate
  • Camel :: Kamelet Main
  • Camel :: Launcher
  • Camel :: Launcher :: Container
  • Camel :: OpenSearch Java API Client
  • Camel :: YAML DSL
  • Camel :: YAML DSL :: Deserializers
  • Camel :: YAML DSL :: Maven Plugins
  • Camel :: YAML DSL :: Validator
  • Camel :: YAML DSL :: Validator Maven Plugin

⚙️ View full build and test results

@davsclaus davsclaus added this to the 4.22.3 milestone Oct 18, 2026
@davsclaus davsclaus added backport indicate that a Pull request is a backport from a fix from the main branch bug Something isn't working labels Oct 18, 2026
@davsclaus
davsclaus merged commit b2b62cb into apache:camel-4.22.x Oct 18, 2026
4 checks passed
@oscerd
oscerd deleted the backport/CAMEL-25706-25708-to-camel-4.22.x branch October 19, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport indicate that a Pull request is a backport from a fix from the main branch bug Something isn't working components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants