stac-utils / stac-fastapi-elasticsearch-opensearch

Elasticsearch backend for stac-fastapi with Opensearch support.
https://stac-utils.github.io/stac-fastapi-elasticsearch-opensearch
MIT License
31 stars 15 forks source link

Add the option to include basic Auth #225

Closed jonhealy1 closed 6 months ago

jonhealy1 commented 7 months ago

I think this would be a good first step. It's definitely imperative that Users can turn on and off the option for their own deployment as Users may want to implement their own solution or use services provided by their cloud-provider.

rhysrevans3 commented 7 months ago

The stac-fastapi base allows you too add route-dependencies at app creation:

routes = [
    {"path": "/collections", "method": "POST"},
    {"path": "/collections/{collectionId}", "method": "PUT"},
    {"path": "/collections/{collectionId}", "method": "DELETE"},
    {"path": "/collections/{collectionId}/items", "method": "POST"},
    {"path": "/collections/{collectionId}/items/{itemId}", "method": "PUT"},
    {"path": "/collections/{collectionId}/items/{itemId}", "method": "DELETE"},
]
dependencies = [Depends(must_be_bob)]
StacApi(
    title=os.getenv("STAC_FASTAPI_TITLE", "stac-fastapi-elasticsearch"),
    description=os.getenv("STAC_FASTAPI_DESCRIPTION", "stac-fastapi-elasticsearch"),
    api_version=os.getenv("STAC_FASTAPI_VERSION", "2.1"),
    settings=settings,
    extensions=extensions,
    client=CoreClient(
        database=database_logic, session=session, post_request_model=post_request_model
    ),
    search_get_request_model=create_get_request_model(extensions),
    search_post_request_model=post_request_model,
    route_dependencies=[(routes, dependencies)]
)

Or after the apps been created:

api.add_route_dependencies(scopes=routes, dependencies=[Depends(must_be_bob)])

I'm not sure the best way to include this in the current workflows. I've been overwriting the whole app.py.

jonhealy1 commented 7 months ago

Hi @rhysrevans3. Can you look at this pr https://github.com/Healy-Hyperspatial/stac-fastapi-mongo/pull/13? We are thinking about adding this here also.

pedro-cf commented 6 months ago

@jonhealy1 this can be closed now :)