Skip to content

Commit

Permalink
Fix for missing auth headers in sniff_callback
Browse files Browse the repository at this point in the history
  • Loading branch information
acidvegas committed Feb 28, 2024
1 parent 74a531c commit 2faeba4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion elasticsearch/_sync/client/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.

import base64
import re
import warnings
from typing import (
Expand Down Expand Up @@ -166,13 +167,23 @@ def _sniffed_node_callback(
def sniff_callback(
transport: Transport, sniff_options: SniffOptions
) -> List[NodeConfig]:
# Dynamically resolve authentication headers based on the client's configuration.
auth_headers = resolve_auth_headers(
headers=None,
http_auth=transport.http_auth,
api_key=transport.api_key,
basic_auth=transport.basic_auth,
bearer_auth=transport.bearer_auth,
)

for _ in transport.node_pool.all():
try:
meta, node_infos = transport.perform_request(
"GET",
"/_nodes/_all/http",
headers={
"accept": "application/vnd.elasticsearch+json; compatible-with=8"
**auth_headers, # Include the resolved authentication headers
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
},
request_timeout=(
sniff_options.sniff_timeout
Expand Down

0 comments on commit 2faeba4

Please sign in to comment.