File tree Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Expand file tree Collapse file tree 2 files changed +15
-13
lines changed Original file line number Diff line number Diff line change @@ -31,11 +31,19 @@ def create_app(settings: Optional[Settings] = None) -> FastAPI:
3131
3232 proxy = ReverseProxy (upstream = str (settings .upstream_url ))
3333
34+ openapi_handler = OpenApiSpecHandler (
35+ proxy = proxy , oidc_config_url = str (settings .oidc_discovery_url )
36+ ).dispatch
37+
3438 # Endpoints that are explicitely marked private
3539 for path , methods in settings .private_endpoints .items ():
3640 app .add_api_route (
3741 path ,
38- proxy .stream ,
42+ (
43+ proxy .stream
44+ if not path == settings .openapi_spec_endpoint
45+ else openapi_handler
46+ ),
3947 methods = methods ,
4048 dependencies = [Depends (auth_scheme )],
4149 )
@@ -44,20 +52,14 @@ def create_app(settings: Optional[Settings] = None) -> FastAPI:
4452 for path , methods in settings .public_endpoints .items ():
4553 app .add_api_route (
4654 path ,
47- proxy .stream ,
55+ (
56+ proxy .stream
57+ if not path == settings .openapi_spec_endpoint
58+ else openapi_handler
59+ ),
4860 methods = methods ,
4961 )
5062
51- # Endpoint with special OpenAPI transformation functionality
52- if settings .openapi_spec_endpoint :
53- app .add_api_route (
54- settings .openapi_spec_endpoint ,
55- OpenApiSpecHandler (
56- proxy = proxy , oidc_config_url = str (settings .oidc_discovery_url )
57- ).dispatch ,
58- methods = ["GET" ],
59- )
60-
6163 # Catchall for remainder of the endpoints
6264 app .add_api_route (
6365 "/{path:path}" ,
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ class Settings(BaseSettings):
2626 # https://stac-utils.github.io/stac-fastapi/api/stac_fastapi/extensions/third_party/bulk_transactions/#bulktransactionextension
2727 "/collections/{collection_id}/bulk_items" : ["POST" ],
2828 }
29- public_endpoints : EndpointMethods = {"/api.html" : ["GET" ]}
29+ public_endpoints : EndpointMethods = {"/api.html" : ["GET" ], "/api" : [ "GET" ] }
3030 openapi_spec_endpoint : Optional [str ] = None
3131
3232 model_config = SettingsConfigDict (env_prefix = "STAC_AUTH_PROXY_" )
You can’t perform that action at this time.
0 commit comments