From eed56fa4505f68b235f5855b24e62328943ce7f8 Mon Sep 17 00:00:00 2001 From: Marvin Zhang Date: Fri, 15 Apr 2022 13:17:57 +0800 Subject: [PATCH] fixed es auth issue --- python/crawlab/config/__init__.py | 2 +- python/crawlab/db/es.py | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/python/crawlab/config/__init__.py b/python/crawlab/config/__init__.py index c3e0bec..38f3a1d 100644 --- a/python/crawlab/config/__init__.py +++ b/python/crawlab/config/__init__.py @@ -1 +1 @@ -VERSION = '0.3.5' +VERSION = '0.3.6' diff --git a/python/crawlab/db/es.py b/python/crawlab/db/es.py index 8774da3..0d75e01 100644 --- a/python/crawlab/db/es.py +++ b/python/crawlab/db/es.py @@ -1,5 +1,3 @@ -import json - import elasticsearch as elasticsearch from crawlab.utils.config import get_data_source @@ -7,12 +5,15 @@ def get_client() -> elasticsearch.Elasticsearch: ds = get_data_source() - base_auth = None + http_auth = None if ds.get('username') is not None and ds.get('password') is not None: - base_auth = (ds.get('username'), ds.get('password')) + http_auth = f'{ds.get("username")}:{ds.get("password")}' return elasticsearch.Elasticsearch( - hosts=[{'host': ds.get('host'), 'port': ds.get('port')}], - basic_auth=base_auth, + hosts=[{ + 'host': ds.get('host'), + 'port': ds.get('port'), + 'http_auth': http_auth, + }], )