Skip to content

Commit 295694b

Browse files
author
Grzegorz Pustulka
committed
Database authorization capability with SSL disabled
1 parent b0450eb commit 295694b

File tree

2 files changed

+16
-16
lines changed
  • stac_fastapi
    • elasticsearch/stac_fastapi/elasticsearch
    • opensearch/stac_fastapi/opensearch

2 files changed

+16
-16
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ def _es_config() -> Dict[str, Any]:
5151
if http_compress:
5252
config["http_compress"] = True
5353

54+
# Handle authentication
55+
if (u := os.getenv("ES_USER")) and (p := os.getenv("ES_PASS")):
56+
config["http_auth"] = (u, p)
57+
5458
# Explicitly exclude SSL settings when not using SSL
5559
if not use_ssl:
5660
return config
@@ -63,10 +67,6 @@ def _es_config() -> Dict[str, Any]:
6367
if config["verify_certs"]:
6468
config["ca_certs"] = os.getenv("CURL_CA_BUNDLE", certifi.where())
6569

66-
# Handle authentication
67-
if (u := os.getenv("ES_USER")) and (p := os.getenv("ES_PASS")):
68-
config["http_auth"] = (u, p)
69-
7070
return config
7171

7272

stac_fastapi/opensearch/stac_fastapi/opensearch/config.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,6 @@ def _es_config() -> Dict[str, Any]:
3939
if http_compress:
4040
config["http_compress"] = True
4141

42-
# Explicitly exclude SSL settings when not using SSL
43-
if not use_ssl:
44-
return config
45-
46-
# Include SSL settings if using https
47-
config["ssl_version"] = ssl.PROTOCOL_SSLv23
48-
config["verify_certs"] = get_bool_env("ES_VERIFY_CERTS", default=True)
49-
50-
# Include CA Certificates if verifying certs
51-
if config["verify_certs"]:
52-
config["ca_certs"] = os.getenv("CURL_CA_BUNDLE", certifi.where())
53-
5442
# Handle authentication
5543
if (u := os.getenv("ES_USER")) and (p := os.getenv("ES_PASS")):
5644
config["http_auth"] = (u, p)
@@ -64,6 +52,18 @@ def _es_config() -> Dict[str, Any]:
6452

6553
config["headers"] = headers
6654

55+
# Explicitly exclude SSL settings when not using SSL
56+
if not use_ssl:
57+
return config
58+
59+
# Include SSL settings if using https
60+
config["ssl_version"] = ssl.PROTOCOL_SSLv23
61+
config["verify_certs"] = get_bool_env("ES_VERIFY_CERTS", default=True)
62+
63+
# Include CA Certificates if verifying certs
64+
if config["verify_certs"]:
65+
config["ca_certs"] = os.getenv("CURL_CA_BUNDLE", certifi.where())
66+
6767
return config
6868

6969

0 commit comments

Comments
 (0)