Closed jonhealy1 closed 6 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
.
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.
@jonhealy1 this can be closed now :)
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.