about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJeong Arm <kjwonmail@gmail.com>2021-10-25 00:20:03 +0900
committerGitHub <noreply@github.com>2021-10-24 17:20:03 +0200
commitc8ce728705c0a5f85e55ed68101938a04f94ffb3 (patch)
treebe9975217462215c4fbc4b8f0e6b9e90f088c223
parentec059317fad4fc5f1ed45a72cbae48edafcb586d (diff)
Support authentication for ElasticSearch (#16890)
* Support authentication for ElasticSearch

* Fix chewy auth settings
-rw-r--r--.env.production.sample3
-rw-r--r--config/initializers/chewy.rb4
2 files changed, 7 insertions, 0 deletions
diff --git a/.env.production.sample b/.env.production.sample
index 6f14c5804..86ae5d111 100644
--- a/.env.production.sample
+++ b/.env.production.sample
@@ -28,6 +28,9 @@ DB_PORT=5432
 ES_ENABLED=true
 ES_HOST=localhost
 ES_PORT=9200
+# Authentication for ES (optional)
+ES_USER=elastic
+ES_PASS=password
 
 # Secrets
 # -------
diff --git a/config/initializers/chewy.rb b/config/initializers/chewy.rb
index 9fc9b2f1a..820182a21 100644
--- a/config/initializers/chewy.rb
+++ b/config/initializers/chewy.rb
@@ -1,6 +1,8 @@
 enabled         = ENV['ES_ENABLED'] == 'true'
 host            = ENV.fetch('ES_HOST') { 'localhost' }
 port            = ENV.fetch('ES_PORT') { 9200 }
+user            = ENV.fetch('ES_USER') { nil }
+password        = ENV.fetch('ES_PASS') { nil }
 fallback_prefix = ENV.fetch('REDIS_NAMESPACE') { nil }
 prefix          = ENV.fetch('ES_PREFIX') { fallback_prefix }
 
@@ -9,6 +11,8 @@ Chewy.settings = {
   prefix: prefix,
   enabled: enabled,
   journal: false,
+  user: user,
+  password: password,
   sidekiq: { queue: 'pull' },
 }