Skip to content

Database authorization capability with SSL disabled #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

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

### Fixed

- Added the ability to authenticate with OpenSearch/ElasticSearch with SSL disabled [#388](https://github.com/stac-utils/stac-fastapi-elasticsearch-opensearch/pull/388)

## [v5.0.0a0] - 2025-05-29

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def _es_config() -> Dict[str, Any]:
if http_compress:
config["http_compress"] = True

# Handle authentication
if (u := os.getenv("ES_USER")) and (p := os.getenv("ES_PASS")):
config["http_auth"] = (u, p)

# Explicitly exclude SSL settings when not using SSL
if not use_ssl:
return config
Expand All @@ -64,10 +68,6 @@ def _es_config() -> Dict[str, Any]:
if config["verify_certs"]:
config["ca_certs"] = os.getenv("CURL_CA_BUNDLE", certifi.where())

# Handle authentication
if (u := os.getenv("ES_USER")) and (p := os.getenv("ES_PASS")):
config["http_auth"] = (u, p)

return config


Expand Down
24 changes: 12 additions & 12 deletions stac_fastapi/opensearch/stac_fastapi/opensearch/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,6 @@ def _es_config() -> Dict[str, Any]:
if http_compress:
config["http_compress"] = True

# Explicitly exclude SSL settings when not using SSL
if not use_ssl:
return config

# Include SSL settings if using https
config["ssl_version"] = ssl.PROTOCOL_SSLv23
config["verify_certs"] = get_bool_env("ES_VERIFY_CERTS", default=True)

# Include CA Certificates if verifying certs
if config["verify_certs"]:
config["ca_certs"] = os.getenv("CURL_CA_BUNDLE", certifi.where())

# Handle authentication
if (u := os.getenv("ES_USER")) and (p := os.getenv("ES_PASS")):
config["http_auth"] = (u, p)
Expand All @@ -65,6 +53,18 @@ def _es_config() -> Dict[str, Any]:

config["headers"] = headers

# Explicitly exclude SSL settings when not using SSL
if not use_ssl:
return config

# Include SSL settings if using https
config["ssl_version"] = ssl.PROTOCOL_SSLv23
config["verify_certs"] = get_bool_env("ES_VERIFY_CERTS", default=True)

# Include CA Certificates if verifying certs
if config["verify_certs"]:
config["ca_certs"] = os.getenv("CURL_CA_BUNDLE", certifi.where())

return config


Expand Down