Skip to content

Commit

Permalink
feat(configuraton): add elasticsearch ca_cert path variable (#1502)
Browse files Browse the repository at this point in the history
* Add ca_cert path variable

* Fix

* Update src/rubrix/server/commons/settings.py

Co-authored-by: Francisco Aranda <frascuchon@gmail.com>

* Add to docs

* fix: include missing imports

* chore: fix transformers dep for dev

Co-authored-by: zel.a <zel.a@medlinx.online>
Co-authored-by: Anastasia <60486232+zelanastasia@users.noreply.github.com>
(cherry picked from commit e8f5613)
  • Loading branch information
Francisco Aranda committed Jun 7, 2022
1 parent 5172324 commit f0eda12
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/getting_started/advanced_setup_guides.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Server

- ``RUBRIX_ELASTICSEARCH_SSL_VERIFY``: If "False", disables SSL certificate verification when connection to the Elasticsearch backend.

- ``RUBRIX_ELASTICSEARCH_CA_PATH``: Path to CA cert for ES host. For example: '/full/path/to/root-ca.pem' (Optional)

- ``RUBRIX_NAMESPACE``: A prefix used to manage Elasticsearch indices. You can use this namespace to use the same Elasticsearch instance for several independent Rubrix instances.

- ``RUBRIX_DEFAULT_ES_SEARCH_ANALYZER``: Default analyzer for textual fields excluding the metadata (Default: "standard").
Expand Down
1 change: 1 addition & 0 deletions src/rubrix/server/commons/es_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def get_instance(cls) -> "ElasticsearchWrapper":
es_client = OpenSearch(
hosts=settings.elasticsearch,
verify_certs=settings.elasticsearch_ssl_verify,
ca_certs=settings.elasticsearch_ca_path,
# Extra args to es configuration -> TODO: extensible by settings
retry_on_timeout=True,
max_retries=5,
Expand Down
6 changes: 5 additions & 1 deletion src/rubrix/server/commons/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Common environment vars / settings
"""
import logging
from typing import List
from typing import List, Optional
from urllib.parse import urlparse

from pydantic import BaseSettings, Field, validator
Expand Down Expand Up @@ -60,6 +60,7 @@ class ApiSettings(BaseSettings):

elasticsearch: str = "http://localhost:9200"
elasticsearch_ssl_verify: bool = True
elasticsearch_ca_path: Optional[str] = None
cors_origins: List[str] = ["*"]

docs_enabled: bool = True
Expand Down Expand Up @@ -117,6 +118,9 @@ def obfuscated_elasticsearch(self) -> str:
class Config:
# TODO: include a common prefix for all rubrix env vars.
fields = {
"elasticsearch_ca_path": {
"env": "RUBRIX_ELASTICSEARCH_CA_PATH",
},
"elasticsearch_ssl_verify": {
"env": "RUBRIX_ELASTICSEARCH_SSL_VERIFY",
},
Expand Down

0 comments on commit f0eda12

Please sign in to comment.