Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0a94081
new code
amarouane-ABDELHAK Jul 10, 2025
0b59cd8
Support STAC-API multi tenants PoC
amarouane-ABDELHAK Jul 10, 2025
c73c2b6
feat: add middleware, create tenant context in model
botanical Sep 16, 2025
f60c812
feat: add TenantSearchRequest model
botanical Sep 16, 2025
9ddbb2e
feat: add specific tenant validation error class
botanical Sep 16, 2025
223088a
fix: update error handling
botanical Sep 16, 2025
4008178
feat: add functon for adding tenant filter to search
botanical Sep 16, 2025
bda72b2
fix: add missing conf field for search request
botanical Sep 16, 2025
0f789f2
fix: move code from app to tenant_client and tenant_routes
botanical Sep 16, 2025
6572f0e
Merge branch 'develop' into poc/support-multi-tenants
botanical Sep 16, 2025
0974e74
fix: update post model which broke from merge changes
botanical Sep 16, 2025
7dd0747
fix: landing page links generation
botanical Sep 16, 2025
43f4e26
fix: docstrings, formatting, and unit tests
botanical Sep 16, 2025
7f1da50
fix: add more docstrings
botanical Sep 16, 2025
b805636
fix: add logging to landing page for debugging
botanical Sep 16, 2025
a648cd9
fix: formatting and typos
botanical Sep 16, 2025
6d63e54
fix: add logging to landing page fn
botanical Sep 17, 2025
83ae864
fix: update old var name
botanical Sep 17, 2025
0d0d77f
feat: add more unit tests
botanical Sep 17, 2025
bcddd4f
fix: fix typo in tenant_client rel retrieval, update tests
botanical Sep 17, 2025
d736671
fix: update landing page logic to exclude queryables
botanical Sep 17, 2025
8eb8573
fix: add valid_stac_collection_with_tenant to params
botanical Sep 17, 2025
c79ab59
fix: lint errors
botanical Sep 17, 2025
a08e553
fix: update collection_in_db to yield dictionary
botanical Sep 17, 2025
6bdfc18
fix: update tests to accomodate for additional tenant collection
botanical Sep 17, 2025
76c2f47
fix: update exception handling in middleware
botanical Sep 17, 2025
07e1115
fix: update tests, try disabling ssl verifications
botanical Sep 17, 2025
68d2fbf
fix: formatting
botanical Sep 17, 2025
3595fc5
fix: try removing proj:projjson in testing
botanical Sep 17, 2025
6283a51
fix: formatting
botanical Sep 17, 2025
0ae9609
fix: see if ssl disabling is necessary
botanical Sep 17, 2025
e642dc3
fix: remove custom landing page, update tests, remove trailing slashe…
botanical Sep 23, 2025
74d3758
fix: add back import, add route to get collections, add another condi…
botanical Sep 23, 2025
e4ccf31
fix: formatting
botanical Sep 23, 2025
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
3 changes: 3 additions & 0 deletions .github/workflows/data/noaa-emergency-response.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"title": "NOAA Emergency Response Imagery",
"description": "NOAA Emergency Response Imagery hosted on AWS Public Dataset.",
"stac_version": "1.0.0",
"properties": {
"tenant": "test-tenant"
},
"license": "public-domain",
"links": [],
"extent": {
Expand Down
37 changes: 33 additions & 4 deletions stac_api/runtime/src/app.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""FastAPI application using PGStac.
"""FastAPI application using PGStac with integrated tenant filtering.
Based on https://github.com/developmentseed/eoAPI/tree/master/src/eoapi/stac
"""

Expand Down Expand Up @@ -27,8 +27,10 @@
from starlette.templating import Jinja2Templates
from starlette_cramjam.middleware import CompressionMiddleware

from .core import VedaCrudClient
from .monitoring import LoggerRouteHandler, logger, metrics, tracer
from .tenant_client import TenantAwareVedaCrudClient
from .tenant_middleware import TenantMiddleware
from .tenant_routes import create_tenant_router
from .validation import ValidationMiddleware

from eoapi.auth_utils import OpenIdConnectAuth, OpenIdConnectSettings
Expand All @@ -54,6 +56,8 @@ async def lifespan(app: FastAPI):
await close_db_connection(app)


tenant_client = TenantAwareVedaCrudClient(pgstac_search_model=post_request_model)

api = StacApi(
app=FastAPI(
title=f"{api_settings.project_name} STAC API",
Expand All @@ -76,17 +80,28 @@ async def lifespan(app: FastAPI):
description=api_settings.project_description,
settings=api_settings,
extensions=application_extensions,
client=VedaCrudClient(pgstac_search_model=post_request_model),
client=tenant_client,
search_get_request_model=get_request_model,
search_post_request_model=post_request_model,
collections_get_request_model=collections_get_request_model,
items_get_request_model=items_get_request_model,
response_class=ORJSONResponse,
middlewares=[Middleware(CompressionMiddleware), Middleware(ValidationMiddleware)],
middlewares=[
Middleware(CompressionMiddleware),
Middleware(ValidationMiddleware),
Middleware(TenantMiddleware),
],
router=APIRouter(route_class=LoggerRouteHandler),
)
app = api.app

# Add tenant-specific routes
logger.info("Creating tenant router...")
tenant_router = create_tenant_router(tenant_client)
logger.info(f"Registering tenant router with {len(tenant_router.routes)} routes")
app.include_router(tenant_router, tags=["Tenant-specific endpoints"])
logger.info("Tenant router registered successfully")

# Set all CORS enabled origins
if api_settings.cors_origins:
app.add_middleware(
Expand Down Expand Up @@ -143,6 +158,20 @@ async def viewer_page(request: Request):
)


@app.get("/{tenant}/index.html", response_class=HTMLResponse)
async def tenant_viewer_page(request: Request, tenant: str):
"""Tenant-specific search viewer."""
return templates.TemplateResponse(
"stac-viewer.html",
{
"request": request,
"endpoint": str(request.url).replace("/index.html", f"/{tenant}"),
"tenant": tenant,
},
media_type="text/html",
)


# If the correlation header is used in the UI, we can analyze traces that originate from a given user or client
@app.middleware("http")
async def add_correlation_id(request: Request, call_next):
Expand Down
Loading