Skip to content

Commit b3dabfe

Browse files
GrzegorzPustulkaGrzegorz Pustulka
and
Grzegorz Pustulka
authored
Database authorization capability with SSL disabled (#388)
**Related Issue(s):** - #387 **Description:** possibility of authorization with disabled ssl **PR Checklist:** - [ ] Code is formatted and linted (run `pre-commit run --all-files`) - [ ] Tests pass (run `make test`) - [ ] Documentation has been updated to reflect changes, if applicable - [ ] Changes are added to the changelog --------- Co-authored-by: Grzegorz Pustulka <[email protected]>
1 parent 3930769 commit b3dabfe

File tree

3 files changed

+20
-16
lines changed

3 files changed

+20
-16
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1212

1313
- Updated mkdocs/ sfeos doucmentation page [#386](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/386)
1414

15+
### Fixed
16+
17+
- Added the ability to authenticate with OpenSearch/ElasticSearch with SSL disabled [#388](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/388)
18+
1519
## [v5.0.0a0] - 2025-05-29
1620

1721
### Added

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/config.py

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

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

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

7373

stac_fastapi/opensearch/stac_fastapi/opensearch/config.py

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

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

6654
config["headers"] = headers
6755

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

7070

0 commit comments

Comments
 (0)