@@ -21,25 +21,25 @@ def create_app(settings: Optional[Settings] = None) -> FastAPI:
2121 app = FastAPI (openapi_url = None )
2222 app .add_middleware (AddProcessTimeHeaderMiddleware )
2323
24- open_id_connect_scheme = OpenIdConnect (
24+ auth_scheme = OpenIdConnect (
2525 openIdConnectUrl = str (settings .oidc_discovery_url ),
2626 scheme_name = "OpenID Connect" ,
2727 description = "OpenID Connect authentication for STAC API access" ,
2828 )
2929
3030 proxy = ReverseProxy (upstream = str (settings .upstream_url ))
3131
32- # Transactions Extension Endpoins
33- for path , methods in {
34- # https://github.com/stac-api-extensions/collection-transaction/blob/v1.0.0-beta.1/README.md#methods
35- "/collections" : [ "POST" ] ,
36- "/collections/{collection_id}" : [ "PUT" , "PATCH" , "DELETE" ] ,
37- # https://github.com/stac-api-extensions/transaction/blob/v1.0.0-rc.3/README.md# methods
38- "/collections/{collection_id}/items" : [ "POST" ],
39- "/collections/{collection_id}/items/{item_id}" : [ "PUT" , "PATCH" , "DELETE" ],
40- # https://stac-utils.github.io/stac-fastapi/api/stac_fastapi/extensions/third_party/bulk_transactions/#bulktransactionextension
41- "/collections/{collection_id}/bulk_items" : [ "POST" ],
42- } .items ():
32+ # Endpoints that are explicitely marked private
33+ for path , methods in settings . private_endpoints . items ():
34+ app . add_api_route (
35+ path ,
36+ proxy . stream ,
37+ methods = methods ,
38+ dependencies = [ Depends ( auth_scheme ) ],
39+ )
40+
41+ # Endpoints that are explicitely marked as public
42+ for path , methods in settings . public_endpoints .items ():
4343 app .add_api_route (
4444 path ,
4545 proxy .stream ,
@@ -56,7 +56,12 @@ def create_app(settings: Optional[Settings] = None) -> FastAPI:
5656 methods = ["GET" ],
5757 )
5858
59- # Catchall proxy
60- app .add_route ("/{path:path}" , proxy .stream )
59+ # Catchall for remainder of the endpoints
60+ app .add_api_route (
61+ "/{path:path}" ,
62+ proxy .stream ,
63+ methods = ["GET" , "POST" , "PUT" , "PATCH" , "DELETE" ],
64+ dependencies = ([] if settings .default_public else [Depends (auth_scheme )]),
65+ )
6166
6267 return app
0 commit comments