diff --git a/docker-compose-base.yaml b/docker-compose-base.yaml index 5fa04782..465b8cc6 100644 --- a/docker-compose-base.yaml +++ b/docker-compose-base.yaml @@ -17,6 +17,8 @@ x-common-variables: &common-variables POSTGRES_DATABASE: retraced LOG_LEVEL: ${LOG_LEVEL} ELASTICSEARCH_NODES: http://elasticsearch:9200 + ELASTIC_PASSWORD: secret + ELASTIC_USER: elastic NSQD_HOST: nsqd HOSTNAME: retraced-api-67856674bf-kwq7f NSQD_TCP_PORT: 4150 diff --git a/src/config.ts b/src/config.ts index ff98831d..a17222a0 100644 --- a/src/config.ts +++ b/src/config.ts @@ -36,6 +36,8 @@ export default { RETRACED_DB_NO_CACHE: process.env.RETRACED_DB_NO_CACHE || env.RETRACED_DB_NO_CACHE, ELASTICSEARCH_CAFILE: process.env.ELASTICSEARCH_CAFILE || env.ELASTICSEARCH_CAFILE, ELASTICSEARCH_CACERT: process.env.ELASTICSEARCH_CACERT || env.ELASTICSEARCH_CACERT, + ELASTICSEARCH_USER: process.env.ELASTIC_USER || env.ELASTIC_USER, + LASTICSEARCH_PASSWORD: process.env.ELASTIC_PASSWORD || env.ELASTIC_PASSWORD, HEADLESS_PROJECT_ENV: process.env.HEADLESS_PROJECT_ENV || env.HEADLESS_PROJECT_ENV, RETRACED_PROCESSOR_LOG_FILE: process.env.RETRACED_PROCESSOR_LOG_FILE || env.RETRACED_PROCESSOR_LOG_FILE, ELASTICSEARCH_REQUEST_RETRIES: diff --git a/src/persistence/elasticsearch.ts b/src/persistence/elasticsearch.ts index b825df21..ed7ff8fd 100644 --- a/src/persistence/elasticsearch.ts +++ b/src/persistence/elasticsearch.ts @@ -47,6 +47,10 @@ function getElasticsearch(noRetry = false): Client { ? readFileSync(config.ELASTICSEARCH_CAFILE) : Buffer.from(config.ELASTICSEARCH_CACERT, "base64"); sslSettings.rejectUnauthorized = true; + sslSettings.auth = { + username: config.ELASTICSEARCH_USER, + password: config.LASTICSEARCH_PASSWORD, + }; } es = new Client({ @@ -195,6 +199,10 @@ export async function putAliases(toAdd: AliasDesc[], toRemove: AliasDesc[]): Pro "Content-Type": "application/json", }, httpsAgent: new https.Agent(httpsAgentParams), + auth: { + username: config.ELASTICSEARCH_USER, + password: config.LASTICSEARCH_PASSWORD, + }, }); return data;