Skip to content

#2103 OpenSearchConnection: send the credentials only to the configured addresses - #2173

Open
rzo1 wants to merge 3 commits into
apache:mainfrom
rzo1:fix-2103-opensearch-credentials-scope
Open

rzo1 wants to merge 3 commits into
apache:mainfrom
rzo1:fix-2103-opensearch-credentials-scope

Conversation

@rzo1

@rzo1 rzo1 commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #2103.

In both opensearch and opensearch-java, the Basic credentials were registered for any host. They are now registered only for the host and port of each configured address, so nodes found by the sniffer no longer receive them.

Also logs a warning when:

  • credentials go to a non-loopback address over plain http
  • opensearch.disable.tls.validation is on
  • sniffing and credentials are both enabled

The default scheme stays http, because switching to https would break existing setups.

Release note: with sniffing on (the default), requests to nodes that report an address other than the configured ones are sent without credentials. On a secured cluster, list every node in opensearch.<type>.addresses or disable sniffing.

…nfigured addresses

Both OpenSearchConnection classes, in external/opensearch and
external/opensearch-java, registered the Basic credentials of
opensearch.<type>.user and opensearch.<type>.password for any host, port
and realm (AuthScope.ANY and new AuthScope(null, -1)). In the opensearch
module the sniffer is on by default, so the credentials were also offered
to every node address it learned from the cluster. An address without a
scheme is contacted over plain http, and nothing was logged when the
credentials went out that way, nor when opensearch.disable.tls.validation
turned off certificate and host name checks.

The credentials are now registered for the host and port of each
configured address only. A node the sniffer finds under another host or
port no longer receives them; such nodes have to be listed in the
addresses, or sniffing disabled, if the cluster requires authentication
on them. A WARN says so when sniffing is enabled together with
credentials. When credentials are configured, a WARN is logged at client
creation listing the addresses which use plain http, loopback addresses
excepted so that local setups stay quiet. A WARN is also logged whenever
opensearch.disable.tls.validation is on.

The default scheme for an address without one stays http. Switching it to
https would break every existing setup which gives a bare host name for a
cluster served over http, including the shipped example configuration, so
the warning is used instead. The docs and the example configurations now
describe the scoping and recommend https:// addresses with credentials.
@rzo1 rzo1 added this to the 4.0.0 milestone Sep 19, 2026
@rzo1 rzo1 self-assigned this Sep 19, 2026
@rzo1
rzo1 requested review from dpol1 and jnioche September 19, 2026 17:40

@dpol1 dpol1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Scoping looks right. One thing on sniffing with https addresses, inline.

+ "The credentials are only sent to the configured addresses: "
+ "requests to a node the sniffer finds under another host or "
+ "port are sent without them and fail if the cluster requires "
+ "authentication. List every node in opensearch.{}.addresses "

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this doesn't work with https addresses: the sniffer registers the nodes it finds as Scheme.HTTP, so after the first sniff every request goes over http. shall we pass Scheme.HTTPS to OpenSearchNodesSniffer when the addresses are https?

| opensearch.addresses | - | OpenSearch server address(es).
| opensearch.user | - | Username for authentication (optional).
| opensearch.addresses | - | OpenSearch server address(es). An address without a scheme is contacted over plain http, on port 9200 if none is given; use `https://` when credentials are configured.
| opensearch.user | - | Username for Basic authentication (optional). The credentials are only sent to the hosts and ports listed in the addresses, not to nodes discovered by sniffing under another address; list those nodes in the addresses or disable `opensearch.<type>.sniff`, which is on by default. A warning is logged when sniffing is enabled together with credentials, and if an address other than a loopback one uses plain http.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

opensearch.<type>.sniff isn't in the table, can you add a row?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenSearch addresses default to http and Basic credentials are registered for any host

2 participants