mirror of
https://github.com/domainaware/parsedmarc.git
synced 2026-05-25 05:15:24 +00:00
Merge pull request #191 from White-Knight-IT/master
Allow Basic Auth with Elasticsearch
This commit is contained in:
@@ -219,6 +219,8 @@ def _main():
|
||||
elasticsearch_ssl=True,
|
||||
elasticsearch_ssl_cert_path=None,
|
||||
elasticsearch_monthly_indexes=False,
|
||||
elasticsearch_username=None,
|
||||
elasticsearch_password=None,
|
||||
kafka_hosts=None,
|
||||
kafka_username=None,
|
||||
kafka_password=None,
|
||||
@@ -352,6 +354,12 @@ def _main():
|
||||
if "cert_path" in elasticsearch_config:
|
||||
opts.elasticsearch_ssl_cert_path = elasticsearch_config[
|
||||
"cert_path"]
|
||||
if "user" in elasticsearch_config:
|
||||
opts.elasticsearch_username = elasticsearch_config[
|
||||
"user"]
|
||||
if "password" in elasticsearch_config:
|
||||
opts.elasticsearch_password = elasticsearch_config[
|
||||
"password"]
|
||||
if "splunk_hec" in config.sections():
|
||||
hec_config = config["splunk_hec"]
|
||||
if "url" in hec_config:
|
||||
@@ -488,6 +496,8 @@ def _main():
|
||||
elastic.set_hosts(opts.elasticsearch_hosts,
|
||||
opts.elasticsearch_ssl,
|
||||
opts.elasticsearch_ssl_cert_path,
|
||||
opts.elasticsearch_username,
|
||||
opts.elasticsearch_password,
|
||||
timeout=opts.elasticsearch_timeout)
|
||||
elastic.migrate_indexes(aggregate_indexes=[es_aggregate_index],
|
||||
forensic_indexes=[es_forensic_index])
|
||||
|
||||
@@ -171,7 +171,7 @@ class AlreadySaved(ValueError):
|
||||
"""Raised when a report to be saved matches an existing report"""
|
||||
|
||||
|
||||
def set_hosts(hosts, use_ssl=False, ssl_cert_path=None, timeout=60.0):
|
||||
def set_hosts(hosts, use_ssl=False, ssl_cert_path=None, username=None, password=None, timeout=60.0):
|
||||
"""
|
||||
Sets the Elasticsearch hosts to use
|
||||
|
||||
@@ -194,6 +194,8 @@ def set_hosts(hosts, use_ssl=False, ssl_cert_path=None, timeout=60.0):
|
||||
conn_params['ca_certs'] = ssl_cert_path
|
||||
else:
|
||||
conn_params['verify_certs'] = False
|
||||
if username:
|
||||
conn_params['http_auth']=(username+":"+password)
|
||||
connections.create_connection(**conn_params)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user