Skip to content

Commit

Permalink
Update elastic.py (#449)
Browse files Browse the repository at this point in the history
Insert new config parameter "apiKey" to authenticate via API to Elasticsearch.
  • Loading branch information
UKnowTEd authored Dec 16, 2023
1 parent 37a6155 commit 100f12e
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion parsedmarc/elastic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand All @@ -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)


Expand Down

0 comments on commit 100f12e

Please sign in to comment.