From 100f12ed3571f21d4d321c2827e16e7bfbc99468 Mon Sep 17 00:00:00 2001 From: UKnowTEd <138619650+UKnowTEd@users.noreply.github.com> Date: Sat, 16 Dec 2023 17:59:50 +0100 Subject: [PATCH] Update elastic.py (#449) Insert new config parameter "apiKey" to authenticate via API to Elasticsearch. --- parsedmarc/elastic.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parsedmarc/elastic.py b/parsedmarc/elastic.py index 5e0652c..02198c9 100644 --- a/parsedmarc/elastic.py +++ b/parsedmarc/elastic.py @@ -169,7 +169,7 @@ class AlreadySaved(ValueError): def set_hosts(hosts, use_ssl=False, ssl_cert_path=None, - username=None, password=None, timeout=60.0): + username=None, password=None, apiKey=None, timeout=60.0): """ Sets the Elasticsearch hosts to use @@ -179,6 +179,7 @@ def set_hosts(hosts, use_ssl=False, ssl_cert_path=None, ssl_cert_path (str): Path to the certificate chain username (str): The username to use for authentication password (str): The password to use for authentication + apiKey (str): The Base64 encoded API key to use for authentication timeout (float): Timeout in seconds """ if not isinstance(hosts, list): @@ -196,6 +197,8 @@ def set_hosts(hosts, use_ssl=False, ssl_cert_path=None, conn_params['verify_certs'] = False if username: conn_params['http_auth'] = (username+":"+password) + if apiKey: + conn_params['api_key'] = apiKey connections.create_connection(**conn_params)